Clamp declarable bandwidth at INT32_MAX, not INT_MAX.
svn:r9677
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
#ifndef UINT32_MAX
#define UINT32_MAX 0xffffffffu
#endif
+#ifndef INT32_MAX
+#define INT32_MAX 0x7fffffffu
+#endif
#endif
#if (SIZEOF_LONG == 4)
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;
}
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);
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);