aboutsummaryrefslogtreecommitdiff
path: root/src/or/policies.c
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2008-08-13 12:45:34 +0000
committerPeter Palfrader <peter@palfrader.org>2008-08-13 12:45:34 +0000
commit34e083dde1aa66e2e19faabc6efa1c6f87d7a80f (patch)
treeecb946daff935aa3d2d0b159183fdb737880ac43 /src/or/policies.c
parentb2344a9e4dd5cbd23bc1138d5ba77c4f230fa416 (diff)
downloadtor-34e083dde1aa66e2e19faabc6efa1c6f87d7a80f.tar.gz
tor-34e083dde1aa66e2e19faabc6efa1c6f87d7a80f.zip
Make sure we don't run off the end of the list
svn:r16523
Diffstat (limited to 'src/or/policies.c')
-rw-r--r--src/or/policies.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/or/policies.c b/src/or/policies.c
index cfd6e4bbdc..f0f96e659b 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -1015,13 +1015,14 @@ policy_summary_accept(smartlist_t *summary,
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 @@ policy_summary_reject(smartlist_t *summary,
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: