[or-cvs] r16523: {tor} Make sure we don't run off the end of the list (tor/trunk/src/or)
weasel at seul.org
weasel at seul.org
Wed Aug 13 12:45:35 UTC 2008
Author: weasel
Date: 2008-08-13 08:45:34 -0400 (Wed, 13 Aug 2008)
New Revision: 16523
Modified:
tor/trunk/src/or/policies.c
Log:
Make sure we don't run off the end of the list
Modified: tor/trunk/src/or/policies.c
===================================================================
--- tor/trunk/src/or/policies.c 2008-08-13 12:45:28 UTC (rev 16522)
+++ tor/trunk/src/or/policies.c 2008-08-13 12:45:34 UTC (rev 16523)
@@ -1015,13 +1015,14 @@
uint16_t prt_min, uint16_t prt_max)
{
int i = policy_summary_split(summary, prt_min, prt_max);
- while (AT(i)->prt_max <= prt_max) {
- if (AT(i)->accepted ||
- AT(i)->reject_count > REJECT_CUTOFF_COUNT)
- continue;
- AT(i)->accepted = 1;
+ while (i < smartlist_len(summary) &&
+ AT(i)->prt_max <= prt_max) {
+ if (!AT(i)->accepted &&
+ AT(i)->reject_count <= REJECT_CUTOFF_COUNT)
+ AT(i)->accepted = 1;
i++;
}
+ tor_assert(i < smartlist_len(summary) || prt_max==65535);
}
/** Count the number of addresses in a network with prefixlen maskbits
@@ -1034,10 +1035,12 @@
int i = policy_summary_split(summary, prt_min, prt_max);
/* XXX: ipv4 specific */
int count = (1 << (32-maskbits));
- while (AT(i)->prt_max <= prt_max) {
+ while (i < smartlist_len(summary) &&
+ AT(i)->prt_max <= prt_max) {
AT(i)->reject_count += count;
i++;
}
+ tor_assert(i < smartlist_len(summary) || prt_max==65535);
}
/** Add a single exit policy item to our summary:
More information about the tor-commits
mailing list