From 77e8ed0b8644b5d6bdd5ce46f48976671e1c04d4 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Thu, 14 Jan 2010 12:16:45 -0800 Subject: [PATCH] Fix for memerror if value is out of range. --- clients/memerror.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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; } -- 2.30.2