Fix for lp:1123153 (poor use of strtol).
[awesomized/libmemcached] / clients / memflush.cc
index 81bb2574f27190e64a1d6dba4ddcaa8623ec33cb..17abff70f23049e521e7c2d7fce99058561b070c 100644 (file)
@@ -1,4 +1,5 @@
 /* LibMemcached
+ * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
  * Copyright (C) 2006-2009 Brian Aker
  * All rights reserved.
  *
@@ -8,15 +9,16 @@
  * Summary:
  *
  */
-#include "config.h"
+#include "mem_config.h"
 
+#include <cerrno>
 #include <cstdio>
 #include <cstring>
 #include <getopt.h>
 #include <iostream>
 #include <unistd.h>
 
-#include <libmemcached/memcached.h>
+#include <libmemcached-1.0/memcached.h>
 #include "client_options.h"
 #include "utilities.h"
 
@@ -146,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: