r11981@catbus: nickm | 2007-02-28 11:55:27 -0500

Clamp declarable bandwidth at INT32_MAX, not INT_MAX.


svn:r9677
This commit is contained in:
Nick Mathewson 2007-02-28 16:56:07 +00:00
parent ebf1862382
commit dae5fc7982
5 changed files with 17 additions and 6 deletions

View File

@ -10,6 +10,8 @@ Changes in version 0.1.2.9-??? - 2007-??-??
o Minor bugfixes (other):
- Fix an assert that could trigger if a controller quickly set then
cleared EntryNodes. (Bug found by Udo van den Heuvel.)
- On architectures where sizeof(int)>4, still clamp declarable bandwidth
to INT32_MAX.
Changes in version 0.1.2.8-beta - 2007-02-26

View File

@ -120,6 +120,9 @@ typedef unsigned int uint32_t;
#ifndef UINT32_MAX
#define UINT32_MAX 0xffffffffu
#endif
#ifndef INT32_MAX
#define INT32_MAX 0x7fffffffu
#endif
#endif
#if (SIZEOF_LONG == 4)

View File

@ -2635,15 +2635,15 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (options->KeepalivePeriod < 1)
REJECT("KeepalivePeriod option must be positive.");
if (options->BandwidthRate > INT_MAX) {
if (options->BandwidthRate > ROUTER_MAX_DECLARED_BANDWIDTH) {
r = tor_snprintf(buf, sizeof(buf),
"BandwidthRate must be less than %d",INT_MAX);
"BandwidthRate must be less than %d",INT32_MAX);
*msg = tor_strdup(r >= 0 ? buf : "internal error");
return -1;
}
if (options->BandwidthBurst > INT_MAX) {
if (options->BandwidthBurst > ROUTER_MAX_DECLARED_BANDWIDTH) {
r = tor_snprintf(buf, sizeof(buf),
"BandwidthBurst must be less than %d",INT_MAX);
"BandwidthBurst must be less than %d",INT32_MAX);
*msg = tor_strdup(r >= 0 ? buf : "internal error");
return -1;
}

View File

@ -2903,6 +2903,7 @@ routerinfo_t *router_find_exact_exit_enclave(const char *address,
uint16_t port);
#define ROUTER_REQUIRED_MIN_BANDWIDTH 10000
#define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
int router_is_unreliable(routerinfo_t *router, int need_uptime,
int need_capacity, int need_guard);
uint32_t router_get_advertised_bandwidth(routerinfo_t *router);

View File

@ -877,8 +877,13 @@ router_rebuild_descriptor(int force)
ri->bandwidthburst = (int)options->BandwidthBurst;
ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
if (options->BandwidthRate > options->MaxAdvertisedBandwidth)
if (options->BandwidthRate > options->MaxAdvertisedBandwidth) {
if (options->MaxAdvertisedBandwidth > ROUTER_MAX_DECLARED_BANDWIDTH) {
ri->bandwidthrate = ROUTER_MAX_DECLARED_BANDWIDTH;
} else {
ri->bandwidthrate = (int)options->MaxAdvertisedBandwidth;
}
}
policies_parse_exit_policy(options->ExitPolicy, &ri->exit_policy,
options->ExitPolicyRejectPrivate);