diff options
author | George Kadianakis <desnacked@gmail.com> | 2011-09-11 21:22:37 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@gmail.com> | 2011-09-11 21:22:37 +0200 |
commit | ebc232bb79c8816d17eea75d3a29c1ecb25da0b0 (patch) | |
tree | 83cbdb7e6f65301c1fdd2cffbcfa15830a6d8754 /src/or/config.c | |
parent | 2703e41d8b6ffcad653af68a8261c22b5a1ed26f (diff) | |
download | tor-ebc232bb79c8816d17eea75d3a29c1ecb25da0b0.tar.gz tor-ebc232bb79c8816d17eea75d3a29c1ecb25da0b0.zip |
Fix bug in get_transport_in_state_by_name() when using strcmpstart().
We now split the state lines into smartlists and compare the token
properly. Not that efficient but it's surely correct.
Diffstat (limited to 'src/or/config.c')
-rw-r--r-- | src/or/config.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index bacdae32ea..792124c08b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -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 |