From 38117be0e4d8d0a62f01cfe1a5702bdf358a1fea Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 1 Nov 2008 22:18:58 +0100 Subject: [PATCH] Fix a bug in exec_interactive_command(). In case a command iwthout further options was given, p pointed one byte after the malloced string, and this pointer is passed to the command handler.. --- interactive.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/interactive.c b/interactive.c index 93e4a36..191e633 100644 --- a/interactive.c +++ b/interactive.c @@ -99,8 +99,12 @@ static int exec_interactive_command(char *line) char *p = cmd + strcspn(cmd, delim); int ret = -E_SYNTAX; - *p = '\0'; - p++; + if (*p == '\0') + p = NULL; + else { + *p = '\0'; + p++; + } for (i = 0; icmds[i].name; i++) { ERROR_LOG("name: %s, cmd: %s.\n", icmds[i].name, cmd); if (strcmp(icmds[i].name, cmd)) -- 2.30.2