]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Be more defensive in get_transport_bindaddr().
authorGeorge Kadianakis <desnacked@gmail.com>
Sun, 11 Sep 2011 19:33:02 +0000 (21:33 +0200)
committerGeorge Kadianakis <desnacked@gmail.com>
Sun, 11 Sep 2011 19:33:02 +0000 (21:33 +0200)
Make sure that lines in get_transport_bindaddr() begin with the name
of the transport and a space.

src/or/config.c

index 792124c08b1fceaf053852111005426c031c0302..79c1b1e199a5ae94f675c523f1c42caa9448354a 100644 (file)
@@ -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