aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFredrik Thulin <fredrik@thulin.net>2016-05-30 14:51:36 +0200
committerFredrik Thulin <fredrik@thulin.net>2016-05-30 14:51:36 +0200
commit44b8ff38821a3f410a511be68a1cfe91bed03bbd (patch)
treeeef5c4020beda98584c460be68e5893beaca8d00
parent565a5379d73a8492d247fdd41773096d83fbf941 (diff)
cli_parse_line: bugfix empty first word
-rw-r--r--libcli.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libcli.c b/libcli.c
index b069c28..d97b304 100644
--- a/libcli.c
+++ b/libcli.c
@@ -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)