From: Brian Aker Date: Thu, 14 Jan 2010 20:16:45 +0000 (-0800) Subject: Fix for memerror if value is out of range. X-Git-Tag: 0.40~104 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=77e8ed0b8644b5d6bdd5ce46f48976671e1c04d4;p=awesomized%2Flibmemcached Fix for memerror if value is out of range. --- diff --git a/clients/memerror.c b/clients/memerror.c index 24798a00..84882520 100644 --- a/clients/memerror.c +++ b/clients/memerror.c @@ -31,12 +31,23 @@ static int opt_verbose= 0; int main(int argc, char *argv[]) { + unsigned long value; options_parse(argc, argv); if (argc != 2) return 1; - printf("%s\n", memcached_strerror(NULL, atoi(argv[1]))); + value= strtol(argv[1], (char **) NULL, 10); + + if (value >= MEMCACHED_SUCCESS && value < MEMCACHED_MAXIMUM_RETURN) + { + printf("%s\n", memcached_strerror(NULL, (memcached_return_t)value)); + } + else + { + fprintf(stderr, "Unknown Error Code\n"); + return 1; + } return 0; }