From d4df6c4087676b108cf562f097a7defa8b181937 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Mon, 20 Feb 2017 18:04:45 +1300 Subject: [PATCH] Check that -k argument is provided before trying to use it. Detected by Coverity Scan. Issue 1364726. --- src/main.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 9333c0a8dc..6895d14225 100644 --- a/src/main.cc +++ b/src/main.cc @@ -523,11 +523,11 @@ mainParseOptions(int argc, char *argv[]) /** \par k * Run the administrative action given following the option */ - /** \li When its an unknown option display the usage help. */ - if ((int) strlen(optarg) < 1) + /** \li When it is missing or an unknown option display the usage help. */ + if (!optarg || strlen(optarg) < 1) usage(); - if (!strncmp(optarg, "reconfigure", strlen(optarg))) + else if (!strncmp(optarg, "reconfigure", strlen(optarg))) /** \li On reconfigure send SIGHUP. */ opt_send_signal = SIGHUP; else if (!strncmp(optarg, "rotate", strlen(optarg))) -- 2.47.3