From ffb82bb4f4e34c36653a06c8ae90c6e5db0fdcd8 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Thu, 3 Feb 2011 09:12:39 +0100 Subject: [PATCH 1/1] 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. --- command.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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" -- 2.39.2