From 8221acb64e0dc17a9fc332cb167fb3fe3fa94678 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 22 Aug 2015 16:21:53 +0200 Subject: [PATCH] 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. --- command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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])) -- 2.39.2