From: Andre Noll Date: Thu, 3 Feb 2011 08:12:39 +0000 (+0100) Subject: server: Avoid invalid free() in com_help(). X-Git-Tag: v0.4.6~45^2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=ffb82bb4f4e34c36653a06c8ae90c6e5db0fdcd8;ds=sidebyside server: Avoid invalid free() in com_help(). If the argument to com_help is not a valid command, we try to free uninitialized memory which may lead to a segfault. This bug existed at least since day 1 of the git repo. --- diff --git a/command.c b/command.c index f61ea572..1810e5b1 100644 --- a/command.c +++ b/command.c @@ -387,10 +387,8 @@ int com_help(int fd, int argc, char * const * argv) } /* argument given for help */ cmd = get_cmd_ptr(argv[1], &handler); - if (!cmd) { - free(handler); + if (!cmd) return -E_BAD_CMD; - } perms = cmd_perms_itohuman(cmd->perms); ret = send_va_buffer(fd, "%s - %s\n\n"