From 44b8ff38821a3f410a511be68a1cfe91bed03bbd Mon Sep 17 00:00:00 2001 From: Fredrik Thulin Date: Mon, 30 May 2016 14:51:36 +0200 Subject: cli_parse_line: bugfix empty first word --- libcli.c | 9 ++++++--- 1 file 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) -- cgit v1.2.3