Fix for lp:1123153 (poor use of strtol).
[awesomized/libmemcached] / clients / memflush.cc
index 67df7c7ab5bfe4fcd871a077e7c039024f4fe47b..17abff70f23049e521e7c2d7fce99058561b070c 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include "mem_config.h"
 
+#include <cerrno>
 #include <cstdio>
 #include <cstring>
 #include <getopt.h>
@@ -147,7 +148,13 @@ void options_parse(int argc, char *argv[])
       break;
 
     case OPT_EXPIRE: /* --expire */
+      errno= 0;
       opt_expire= (time_t)strtoll(optarg, (char **)NULL, 10);
+      if (errno != 0)
+      {
+        std::cerr << "Incorrect value passed to --expire: `" << optarg << "`" << std::cerr;
+        exit(EXIT_FAILURE);
+      }
       break;
 
     case OPT_USERNAME: