summaryrefslogtreecommitdiff
path: root/src/or/policies.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-03-17 16:51:48 +0000
committerNick Mathewson <nickm@torproject.org>2008-03-17 16:51:48 +0000
commit9a24158c698bd2cce6ddbea365a15f7e02bddf3a (patch)
tree0985acfd4b19c005ec2391a0538055a997967237 /src/or/policies.c
parent0cccf7375b6ced5a27df4ff04ee4c80eb20abef4 (diff)
downloadtor-9a24158c698bd2cce6ddbea365a15f7e02bddf3a.tar.gz
tor-9a24158c698bd2cce6ddbea365a15f7e02bddf3a.zip
r18880@catbus: nickm | 2008-03-17 12:51:24 -0400
Fix policy-related crash bug found by lodger. svn:r14077
Diffstat (limited to 'src/or/policies.c')
-rw-r--r--src/or/policies.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/or/policies.c b/src/or/policies.c
index 882540edca..20c1fb9186 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -530,7 +530,10 @@ compare_addr_to_addr_policy(uint32_t addr, uint16_t port,
int match = 0;
int maybe = 0;
int i, len;
- len = policy ? smartlist_len(policy) : 0;
+ if (!policy)
+ return ADDR_POLICY_REJECTED;
+
+ len = smartlist_len(policy);
for (i = 0; i < len; ++i) {
addr_policy_t *tmpe = smartlist_get(policy, i);
@@ -764,6 +767,9 @@ exit_policy_is_general_exit(smartlist_t *policy)
static const int ports[] = { 80, 443, 6667 };
int n_allowed = 0;
int i;
+ if (!policy)
+ return 0;
+
for (i = 0; i < 3; ++i) {
SMARTLIST_FOREACH(policy, addr_policy_t *, p, {
if (p->prt_min > ports[i] || p->prt_max < ports[i])
@@ -787,6 +793,8 @@ exit_policy_is_general_exit(smartlist_t *policy)
int
policy_is_reject_star(smartlist_t *policy)
{
+ if (!policy)
+ return 1;
SMARTLIST_FOREACH(policy, addr_policy_t *, p, {
if (p->policy_type == ADDR_POLICY_ACCEPT)
return 0;