[tor-commits] [tor/master] Check return values for tor_addr_parse(default) in config.c

nickm at torproject.org nickm at torproject.org
Tue Mar 24 14:50:59 UTC 2015


commit fec923d72b2cb40f4d696cc1d2306d4c5779bed0
Author: Nick Mathewson <nickm at torproject.org>
Date:   Tue Mar 24 10:46:39 2015 -0400

    Check return values for tor_addr_parse(default) in config.c
    
    In these cases, the address is always a constant "default", so
    should always succeed.  But coverity can't tell that.
    
    Fixes CID 1291645
---
 src/or/config.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index fca350c..cfa5aa7 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5934,7 +5934,8 @@ parse_port_config(smartlist_t *out,
         port = 1;
     } else if (!strcmp(addrport, "auto")) {
       port = CFG_AUTO_PORT;
-      tor_addr_parse(&addr, defaultaddr);
+      int af = tor_addr_parse(&addr, defaultaddr);
+      tor_assert(af >= 0);
     } else if (!strcasecmpend(addrport, ":auto")) {
       char *addrtmp = tor_strndup(addrport, strlen(addrport)-5);
       port = CFG_AUTO_PORT;
@@ -5949,7 +5950,8 @@ parse_port_config(smartlist_t *out,
          "9050" might be a valid address. */
       port = (int) tor_parse_long(addrport, 10, 0, 65535, &ok, NULL);
       if (ok) {
-        tor_addr_parse(&addr, defaultaddr);
+        int af = tor_addr_parse(&addr, defaultaddr);
+        tor_assert(af >= 0);
       } else if (tor_addr_port_lookup(addrport, &addr, &ptmp) == 0) {
         if (ptmp == 0) {
           log_warn(LD_CONFIG, "%sPort line has address but no port", portname);





More information about the tor-commits mailing list