[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Fix the Big Bug in router_compare_addr_to_exit_policy: we u...
- To: or-cvs@freehaven.net
- Subject: [or-cvs] Fix the Big Bug in router_compare_addr_to_exit_policy: we u...
- From: nickm@seul.org (Nick Mathewson)
- Date: Tue, 17 Feb 2004 03:52:05 -0500 (EST)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 17 Feb 2004 03:52:24 -0500
- Reply-to: or-dev@freehaven.net
- Sender: owner-or-cvs@freehaven.net
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv19917/or
Modified Files:
routerlist.c
Log Message:
Fix the Big Bug in router_compare_addr_to_exit_policy: we used port 0
to mean "unknown port". But no exit policy supports (nonexistant)
port 0, except accept *:*, and we had no special handling for 'unknown port'.
Now we do.
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- routerlist.c 17 Feb 2004 08:42:25 -0000 1.24
+++ routerlist.c 17 Feb 2004 08:52:03 -0000 1.25
@@ -404,24 +404,25 @@
int maybe_reject = 0;
int maybe_accept = 0;
int match = 0;
+ int maybe = 0;
struct in_addr in;
struct exit_policy_t *tmpe;
for(tmpe=policy; tmpe; tmpe=tmpe->next) {
log_fn(LOG_DEBUG,"Considering exit policy %s", tmpe->string);
+ maybe = 0;
if (!addr) {
/* Address is unknown. */
- if (tmpe->msk == 0 && (port >= tmpe->prt_min && port <= tmpe->prt_max)) {
- /* The exit policy is accept/reject *:port */
- match = 1;
- } else if (port >= tmpe->prt_min && port <= tmpe->prt_max) {
- if (tmpe->policy_type == EXIT_POLICY_REJECT) {
- /* The exit policy is reject ???:port */
- maybe_reject = 1;
+ if (port >= tmpe->prt_min && port <= tmpe->prt_max) {
+ /* The port definitely matches. */
+ if (tmpe->msk == 0) {
+ match = 1;
} else {
- /* The exit policy is accept ???:port */
- maybe_accept = 1;
+ maybe = 1;
}
+ } else if (!port) {
+ /* The port maybe matches. */
+ maybe = 1;
}
} else {
/* Address is known */
@@ -431,6 +432,12 @@
match = 1;
}
}
+ if (maybe) {
+ if (tmpe->policy_type == EXIT_POLICY_REJECT)
+ maybe_reject = 1;
+ else
+ maybe_accept = 1;
+ }
if (match) {
in.s_addr = htonl(addr);
log_fn(LOG_INFO,"Address %s:%d matches exit policy '%s'",