[Cryptech-Commits] [user/ft/libcli] 02/03: cli_parse_line: bugfix empty first word

git at cryptech.is git at cryptech.is
Tue May 31 13:09:25 UTC 2016


This is an automated email from the git hooks/post-receive script.

fredrik at thulin.net pushed a commit to branch master
in repository user/ft/libcli.

commit 44b8ff38821a3f410a511be68a1cfe91bed03bbd
Author: Fredrik Thulin <fredrik at thulin.net>
AuthorDate: Mon May 30 14:51:36 2016 +0200

    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)



More information about the Commits mailing list