diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-04-15 10:47:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-04-15 10:47:50 -0400 |
commit | d59c4063f393774c2c4328061b1e47c7dbb0250c (patch) | |
tree | d77e0e5fc9ba48720f5c7f61f0d312eaef3b6a0a /src/or/control.c | |
parent | c3e8b7f2da7f5c7fc4d341b533b7031eab90a665 (diff) | |
download | tor-d59c4063f393774c2c4328061b1e47c7dbb0250c.tar.gz tor-d59c4063f393774c2c4328061b1e47c7dbb0250c.zip |
Stop modifying const argument in handle_control_postdescriptor
Fixes 15546.
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/or/control.c b/src/or/control.c index 5ec97bd9af..9b0981d84a 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2733,12 +2733,14 @@ handle_control_postdescriptor(control_connection_t *conn, uint32_t len, uint8_t purpose = ROUTER_PURPOSE_GENERAL; int cache = 0; /* eventually, we may switch this to 1 */ - char *cp = memchr(body, '\n', len); + const char *cp = memchr(body, '\n', len); smartlist_t *args = smartlist_new(); tor_assert(cp); - *cp++ = '\0'; + ++cp; - smartlist_split_string(args, body, " ", + char *cmdline = tor_memdup_nulterm(body, cp-body); + + smartlist_split_string(args, cmdline, " ", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); SMARTLIST_FOREACH_BEGIN(args, char *, option) { if (!strcasecmpstart(option, "purpose=")) { @@ -2787,6 +2789,7 @@ handle_control_postdescriptor(control_connection_t *conn, uint32_t len, done: SMARTLIST_FOREACH(args, char *, arg, tor_free(arg)); smartlist_free(args); + tor_free(cmdline); return 0; } |