diff options
author | Fredrik Thulin <fredrik@thulin.net> | 2016-05-30 14:51:36 +0200 |
---|---|---|
committer | Fredrik Thulin <fredrik@thulin.net> | 2016-05-30 14:51:36 +0200 |
commit | 44b8ff38821a3f410a511be68a1cfe91bed03bbd (patch) | |
tree | eef5c4020beda98584c460be68e5893beaca8d00 /libcli.c | |
parent | 565a5379d73a8492d247fdd41773096d83fbf941 (diff) |
cli_parse_line: bugfix empty first word
Diffstat (limited to 'libcli.c')
-rw-r--r-- | libcli.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -515,9 +515,12 @@ static int cli_parse_line(const char *line, char *words[], int max_words) { int len = p - word_start; - memcpy(ptr, word_start, len); - words[nwords++] = ptr; - ptr += len + 1; + if (len > 1) + { + memcpy(ptr, word_start, len); + words[nwords++] = ptr; + ptr += len + 1; /* buf is memset zero, so we just need to add +1 to get a null terminated word */ + } } if (!*p) |