From: Andre Noll Date: Sat, 22 Aug 2015 14:21:53 +0000 (+0200) Subject: server: Avoid segfault in com_sender(). X-Git-Tag: v0.5.5~5^2~2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=8221acb64e0dc17a9fc332cb167fb3fe3fa94678 server: Avoid segfault in com_sender(). If exactly one argument is given to the sender command, and this argument is the name of an existing sender, the sender command segfaults due to the NULL pointer dereference. The problem is an off-by-one bug in the check for the number of arguments. This patch makes sure we never dereference argv[2] if it is NULL. --- diff --git a/command.c b/command.c index 2e733c5c..f1f00fca 100644 --- a/command.c +++ b/command.c @@ -156,7 +156,7 @@ static int check_sender_args(int argc, char * const * argv, struct sender_comman const char *subcmds[] = {"add", "delete", "allow", "deny", "on", "off", NULL}; scd->sender_num = -1; - if (argc < 2) + if (argc < 3) return -E_COMMAND_SYNTAX; for (i = 0; senders[i].name; i++) if (!strcmp(senders[i].name, argv[1]))