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

[tor-commits] [tor/master] Be more defensive in get_transport_bindaddr().



commit 9a42ec685751b5c5fd21f33cd788810d997f0d6e
Author: George Kadianakis <desnacked@xxxxxxxxx>
Date:   Sun Sep 11 21:33:02 2011 +0200

    Be more defensive in get_transport_bindaddr().
    
    Make sure that lines in get_transport_bindaddr() begin with the name
    of the transport and a space.
---
 src/or/config.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 792124c..79c1b1e 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5823,10 +5823,24 @@ get_transport_in_state_by_name(const char *transport)
 const char *
 get_transport_bindaddr(const char *line, const char *transport)
 {
-  if (strlen(line) < strlen(transport) + 2)
-    return NULL;
-  else
+  char *line_tmp = NULL;
+
+  if (strlen(line) < strlen(transport) + 2) {
+    goto broken_state;
+  } else {
+    /* line should start with the name of the transport and a space.
+       (for example, "obfs2 127.0.0.1:47245") */
+    tor_asprintf(&line_tmp, "%s ", transport);
+    if (strcmpstart(line, line_tmp))
+      goto broken_state;
+
+    tor_free(line_tmp);
     return (line+strlen(transport)+1);
+  }
+
+ broken_state:
+  tor_free(line_tmp);
+  return NULL;
 }
 
 /** Return a static string containing the address:port a proxy



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