From: Amos Jeffries Date: Fri, 17 Feb 2017 04:53:00 +0000 (+1300) Subject: Check that -k argument is provided before trying to use it. X-Git-Tag: M-staged-PR71~265 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2318aeba753e2f684fdcebd98a02fc9d59dd8c9a;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 282930cab3..7e064f717b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -522,11 +522,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)))