From: Andre Noll Date: Sat, 1 Nov 2008 21:18:58 +0000 (+0100) Subject: Fix a bug in exec_interactive_command(). X-Git-Tag: v0.0.4~20 X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=commitdiff_plain;h=38117be0e4d8d0a62f01cfe1a5702bdf358a1fea 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.. --- 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))