]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix bug in get_transport_in_state_by_name() when using strcmpstart().
authorGeorge Kadianakis <desnacked@gmail.com>
Sun, 11 Sep 2011 19:22:37 +0000 (21:22 +0200)
committerGeorge Kadianakis <desnacked@gmail.com>
Sun, 11 Sep 2011 19:22:37 +0000 (21:22 +0200)
We now split the state lines into smartlists and compare the token
properly. Not that efficient but it's surely correct.

src/or/config.c

index bacdae32eacdb539ff94564f87ea32e80c636d8e..792124c08b1fceaf053852111005426c031c0302 100644 (file)
@@ -5787,13 +5787,34 @@ get_transport_in_state_by_name(const char *transport)
 {
   or_state_t *or_state = get_or_state();
   config_line_t *line;
+  config_line_t *ret = NULL;
+  smartlist_t *items = NULL;
 
   for (line = or_state->TransportProxies ; line ; line = line->next) {
     tor_assert(!strcmp(line->key, "TransportProxy"));
-    if (!strcmpstart(line->value, transport))
-      return line;
+
+    items = smartlist_create();
+    smartlist_split_string(items, line->value, NULL,
+                           SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, -1);
+    if (smartlist_len(items) != 2) /* broken state */
+      goto done;
+
+    if (!strcmp(smartlist_get(items, 0), transport)) {
+      ret = line;
+      goto done;
+    }
+
+    SMARTLIST_FOREACH(items, char*, s, tor_free(s));
+    smartlist_free(items);
+    items = NULL;
   }
-  return NULL;
+
+ done:
+  if (items) {
+    SMARTLIST_FOREACH(items, char*, s, tor_free(s));
+    smartlist_free(items);
+  }
+  return ret;
 }
 
 /** Return string containing the address:port part of the