From: Amos Jeffries Date: Sun, 26 Feb 2017 08:52:45 +0000 (+1300) Subject: Check that -k argument is provided before trying to use it. X-Git-Tag: SQUID_3_5_25~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e626dd0819eed3f57c340c4bf940f52127488358;p=thirdparty%2Fsquid.git Check that -k argument is provided before trying to use it. Detected by Coverity Scan. Issue 1364726. --- diff --git a/src/main.cc b/src/main.cc index 2a7e7f3cba..e4d879c207 100644 --- a/src/main.cc +++ b/src/main.cc @@ -425,11 +425,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)))