summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-08 08:24:47 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-08 08:24:47 -0400
commitad3f0953e6da8bf95f2dd754b91705d4c7d80a1e (patch)
treed87dce66d9f145a540a7c4ac82087b27078ec0eb /src/or/control.c
parenteebfe4f5398c94292986c3eab7fc995635c66a21 (diff)
parent7a83cf75dc55dbac91ff5c0daf7c7418493cbea7 (diff)
downloadtor-ad3f0953e6da8bf95f2dd754b91705d4c7d80a1e.tar.gz
tor-ad3f0953e6da8bf95f2dd754b91705d4c7d80a1e.zip
Merge branch 'maint-0.3.1'
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 7497205378..a0077b2a6c 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -3633,12 +3633,15 @@ handle_control_postdescriptor(control_connection_t *conn, uint32_t len,
int cache = 0; /* eventually, we may switch this to 1 */
const char *cp = memchr(body, '\n', len);
- smartlist_t *args = smartlist_new();
- tor_assert(cp);
+
+ if (cp == NULL) {
+ connection_printf_to_buf(conn, "251 Empty body\r\n");
+ return 0;
+ }
++cp;
char *cmdline = tor_memdup_nulterm(body, cp-body);
-
+ smartlist_t *args = smartlist_new();
smartlist_split_string(args, cmdline, " ",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
SMARTLIST_FOREACH_BEGIN(args, char *, option) {
@@ -4231,14 +4234,19 @@ handle_control_hspost(control_connection_t *conn,
const char *body)
{
static const char *opt_server = "SERVER=";
- smartlist_t *args = smartlist_new();
smartlist_t *hs_dirs = NULL;
const char *encoded_desc = body;
size_t encoded_desc_len = len;
char *cp = memchr(body, '\n', len);
+ if (cp == NULL) {
+ connection_printf_to_buf(conn, "251 Empty body\r\n");
+ return 0;
+ }
char *argline = tor_strndup(body, cp-body);
+ smartlist_t *args = smartlist_new();
+
/* If any SERVER= options were specified, try parse the options line */
if (!strcasecmpstart(argline, opt_server)) {
/* encoded_desc begins after a newline character */