Browse Source

r11668@Kushana: nickm | 2006-12-20 22:22:53 -0500
Fix bug found by Keith Skinner: Treat malformed max-ports in address ranges as an error, and dont ignore errors with min-ports even if a max-port is present.


svn:r9168

Nick Mathewson 17 years ago
parent
commit
ca516311e3
2 changed files with 4 additions and 2 deletions
  1. 1 0
      ChangeLog
  2. 3 2
      src/common/util.c

+ 1 - 0
ChangeLog

@@ -78,6 +78,7 @@ Changes in version 0.1.2.5-xxxx - 200?-??-??
       nameservers are configured in /etc/resolv.conf; instead, make the
       user fix resolv.conf or specify nameservers explicitly. (Resolves
       bug 363.)
+    - Stop accepting certain malformed ports in configured exit policies.
 
   o Controller features:
     - Have GETINFO dir/status/* work on hosts with DirPort disabled.

+ 3 - 2
src/common/util.c

@@ -1755,15 +1755,16 @@ parse_port_range(const char *port, uint16_t *port_min_out,
     char *endptr = NULL;
     *port_min_out = (uint16_t) tor_parse_long(port, 10, 1, 65535,
                                               NULL, &endptr);
-    if (*endptr == '-') {
+    if (*endptr == '-' && *port_min_out) {
       port = endptr+1;
       endptr = NULL;
       *port_max_out = (uint16_t) tor_parse_long(port, 10, 1, 65535, NULL,
                                                 &endptr);
       if (*endptr || !*port_max_out) {
         log_warn(LD_GENERAL,
-                 "Malformed port %s on address range rejecting.",
+                 "Malformed port %s on address range; rejecting.",
                  escaped(port));
+        return -1;
       }
     } else if (*endptr || !*port_min_out) {
       log_warn(LD_GENERAL,