[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.5] Don't crash on torrc Vi[rtualAddrNetworkIPv[4|6]] with no option value



commit b08cfc65a78527cc97f4d0aeff3217d5f1c93e08
Author: teor <teor2345@xxxxxxxxx>
Date:   Sun Jan 11 19:33:04 2015 +1100

    Don't crash on torrc Vi[rtualAddrNetworkIPv[4|6]] with no option value
    
    Check for a missing option value in parse_virtual_addr_network
    before asserting on the NULL in tor_addr_parse_mask_ports.
    This avoids crashing on torrc lines like Vi[rtualAddrNetworkIPv[4|6]]
    when no value follows the option.
    
    Bugfix on 0.2.3 (de4cc126cbb5 on 24 November 2012), fixes #14142.
---
 changes/bug14142-parse-virtual-addr |    7 +++++++
 src/or/addressmap.c                 |    6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/changes/bug14142-parse-virtual-addr b/changes/bug14142-parse-virtual-addr
new file mode 100644
index 0000000..f78b7c7
--- /dev/null
+++ b/changes/bug14142-parse-virtual-addr
@@ -0,0 +1,7 @@
+  o Minor bugfixes (client):
+    - Check for a missing option value in parse_virtual_addr_network
+      before asserting on the NULL in tor_addr_parse_mask_ports.
+      This avoids crashing on torrc lines like
+      Vi[rtualAddrNetworkIPv[4|6]] when no value follows the option.
+      Bugfix on 0.2.3 (de4cc126cbb5 on 24 November 2012), fixes #14142.
+      Patch by "teor".
diff --git a/src/or/addressmap.c b/src/or/addressmap.c
index 998770a..4253532 100644
--- a/src/or/addressmap.c
+++ b/src/or/addressmap.c
@@ -738,6 +738,12 @@ parse_virtual_addr_network(const char *val, sa_family_t family,
   const int max_bits = ipv6 ? 40 : 16;
   virtual_addr_conf_t *conf = ipv6 ? &virtaddr_conf_ipv6 : &virtaddr_conf_ipv4;
 
+  if (!val || val[0] == '\0') {
+    if (msg)
+      tor_asprintf(msg, "Value not present (%s) after VirtualAddressNetwork%s",
+                   val?"Empty":"NULL", ipv6?"IPv6":"");
+    return -1;
+  }
   if (tor_addr_parse_mask_ports(val, 0, &addr, &bits, NULL, NULL) < 0) {
     if (msg)
       tor_asprintf(msg, "Error parsing VirtualAddressNetwork%s %s",



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits