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

[tor-commits] [tor/master] Don't do DNS lookups when parsing corrupted managed proxy messages.



commit 53e4452f985cad0947cd8ebfa0a1c198b6a7da7d
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Mon Jun 25 18:30:15 2012 +0300

    Don't do DNS lookups when parsing corrupted managed proxy messages.
    
    The functions parse_{s,c}method_line() were using
    tor_addr_port_lookup() which is capable of doing DNS lookups. DNS
    lookups should not be necessary when parsing {C,S}METHOD lines.
---
 changes/bug6226     |    3 +++
 src/or/transports.c |   30 ++++++++++++++++++++++--------
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/changes/bug6226 b/changes/bug6226
new file mode 100644
index 0000000..7cbee10
--- /dev/null
+++ b/changes/bug6226
@@ -0,0 +1,3 @@
+  o Minor bugfixes:
+    - Don't do DNS lookups when parsing corrupted managed proxy
+      protocol messages. Fixes bug 6226; bugfix on 0.2.3.6-alpha.
diff --git a/src/or/transports.c b/src/or/transports.c
index e43ec6c..4ba2395 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -790,7 +790,8 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
   char *method_name=NULL;
 
   char *addrport=NULL;
-  tor_addr_t addr;
+  tor_addr_t tor_addr;
+  char *address=NULL;
   uint16_t port = 0;
 
   transport_t *transport=NULL;
@@ -814,7 +815,7 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
   }
 
   addrport = smartlist_get(items, 2);
-  if (tor_addr_port_lookup(addrport, &addr, &port)<0) {
+  if (tor_addr_port_split(LOG_PROTOCOL_WARN, addrport, &address, &port)<0) {
     log_warn(LD_CONFIG, "Error parsing transport "
              "address '%s'", addrport);
     goto err;
@@ -826,7 +827,12 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
     goto err;
   }
 
-  transport = transport_new(&addr, port, method_name, PROXY_NONE);
+  if (tor_addr_parse(&tor_addr, address) < 0) {
+    log_warn(LD_CONFIG, "Error parsing transport address '%s'", address);
+    goto err;
+  }
+
+  transport = transport_new(&tor_addr, port, method_name, PROXY_NONE);
   if (!transport)
     goto err;
 
@@ -835,7 +841,7 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
   /* For now, notify the user so that he knows where the server
      transport is listening. */
   log_info(LD_CONFIG, "Server transport %s at %s:%d.",
-           method_name, fmt_addr(&addr), (int)port);
+           method_name, address, (int)port);
 
   r=0;
   goto done;
@@ -846,6 +852,7 @@ parse_smethod_line(const char *line, managed_proxy_t *mp)
  done:
   SMARTLIST_FOREACH(items, char*, s, tor_free(s));
   smartlist_free(items);
+  tor_free(address);
   return r;
 }
 
@@ -863,7 +870,8 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
   int socks_ver=PROXY_NONE;
 
   char *addrport=NULL;
-  tor_addr_t addr;
+  tor_addr_t tor_addr;
+  char *address=NULL;
   uint16_t port = 0;
 
   transport_t *transport=NULL;
@@ -899,7 +907,7 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
   }
 
   addrport = smartlist_get(items, 3);
-  if (tor_addr_port_lookup(addrport, &addr, &port)<0) {
+  if (tor_addr_port_split(LOG_PROTOCOL_WARN, addrport, &address, &port)<0) {
     log_warn(LD_CONFIG, "Error parsing transport "
              "address '%s'", addrport);
     goto err;
@@ -911,7 +919,12 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
     goto err;
   }
 
-  transport = transport_new(&addr, port, method_name, socks_ver);
+  if (tor_addr_parse(&tor_addr, address) < 0) {
+    log_warn(LD_CONFIG, "Error parsing transport address '%s'", address);
+    goto err;
+  }
+
+  transport = transport_new(&tor_addr, port, method_name, socks_ver);
   if (!transport)
     goto err;
 
@@ -919,7 +932,7 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
 
   log_info(LD_CONFIG, "Transport %s at %s:%d with SOCKS %d. "
            "Attached to managed proxy.",
-           method_name, fmt_addr(&addr), (int)port, socks_ver);
+           method_name, address, (int)port, socks_ver);
 
   r=0;
   goto done;
@@ -930,6 +943,7 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
  done:
   SMARTLIST_FOREACH(items, char*, s, tor_free(s));
   smartlist_free(items);
+  tor_free(address);
   return r;
 }
 



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