aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)