diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-02-28 16:56:07 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-02-28 16:56:07 +0000 |
commit | dae5fc798271db3b993be1b38cfada73e05dab68 (patch) | |
tree | 088205a2ec3a8f904b9ed0c10b87c51566481e9c | |
parent | ebf1862382d25f155228325a85a3c11ab48b7b86 (diff) | |
download | tor-dae5fc798271db3b993be1b38cfada73e05dab68.tar tor-dae5fc798271db3b993be1b38cfada73e05dab68.tar.gz |
r11981@catbus: nickm | 2007-02-28 11:55:27 -0500
Clamp declarable bandwidth at INT32_MAX, not INT_MAX.
svn:r9677
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/common/torint.h | 3 | ||||
-rw-r--r-- | src/or/config.c | 8 | ||||
-rw-r--r-- | src/or/or.h | 1 | ||||
-rw-r--r-- | src/or/router.c | 9 |
5 files changed, 17 insertions, 6 deletions
@@ -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 diff --git a/src/common/torint.h b/src/common/torint.h index f1c0f1a62..6cb43a3b3 100644 --- a/src/common/torint.h +++ b/src/common/torint.h @@ -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) diff --git a/src/or/config.c b/src/or/config.c index 70b4dc598..5fa01d59e 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -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; } diff --git a/src/or/or.h b/src/or/or.h index 382010284..fbd559fcc 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -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); diff --git a/src/or/router.c b/src/or/router.c index 881fc9301..24ec0e90c 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -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) - ri->bandwidthrate = (int)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); |