diff options
author | George Kadianakis <desnacked@riseup.net> | 2012-12-17 14:39:24 +0200 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2013-02-09 16:30:16 +0000 |
commit | faf4f6c6d1da54b0a6b0c9946112f2e448867a8f (patch) | |
tree | 2133ca646b70e692ab704cf500e57d54af9b0d0a /src/or/transports.c | |
parent | 757b03aacbf7051194bbe9faa2bfcc59e4cc3392 (diff) | |
download | tor-faf4f6c6d1da54b0a6b0c9946112f2e448867a8f.tar.gz tor-faf4f6c6d1da54b0a6b0c9946112f2e448867a8f.zip |
Validate SOCKS arguments.
Diffstat (limited to 'src/or/transports.c')
-rw-r--r-- | src/or/transports.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/or/transports.c b/src/or/transports.c index 647b293168..a9f7fa2bf5 100644 --- a/src/or/transports.c +++ b/src/or/transports.c @@ -1424,6 +1424,41 @@ pt_get_extra_info_descriptor_string(void) return the_string; } +/** Stringify the SOCKS arguments in <b>socks_args</b> according to + * 180_pluggable_transport.txt. The string is allocated on the heap + * and it's the responsibility of the caller to free it after use. */ +char * +pt_stringify_socks_args(const smartlist_t *socks_args) +{ + /* tmp place to store escaped socks arguments, so that we can + concatenate them up afterwards */ + smartlist_t *sl_tmp = NULL; + char *escaped_string = NULL; + char *new_string = NULL; + + tor_assert(socks_args); + tor_assert(smartlist_len(socks_args) > 0); + + sl_tmp = smartlist_new(); + + SMARTLIST_FOREACH_BEGIN(socks_args, const char *, s) { + /* Escape ';' and '\'. */ + escaped_string = tor_escape_str_for_socks_arg(s); + if (!escaped_string) + goto done; + + smartlist_add(sl_tmp, escaped_string); + } SMARTLIST_FOREACH_END(s); + + new_string = smartlist_join_strings(sl_tmp, ";", 0, NULL); + + done: + SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s)); + smartlist_free(sl_tmp); + + return new_string; +} + /** The tor config was read. * Destroy all managed proxies that were marked by a previous call to * prepare_proxy_list_for_config_read() and are not used by the new |