From c33d45c97ce92ec3ac4748a380d6ba1bc2eb0d79 Mon Sep 17 00:00:00 2001 From: Adham Masarwah Date: Mon, 7 Jul 2014 16:25:36 +0300 Subject: [PATCH] Check the argument for -t if it is number. Signed-off-by: Adham Masarwah --- small_utils/vpd.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/small_utils/vpd.c b/small_utils/vpd.c index 796bc40..bb76a98 100644 --- a/small_utils/vpd.c +++ b/small_utils/vpd.c @@ -531,6 +531,7 @@ int vpd_open(const char *name, int* vpd_path_exists) int main(int argc, char **argv) { const char *name; + char* endptr; int fd; int i; int rc = 0; @@ -568,7 +569,11 @@ int main(int argc, char **argv) ignore_w=1; break; case 't': - timeout_t = strtol(optarg, NULL, 0); + timeout_t = strtol(optarg, &endptr, 0); + if (*endptr != '\0') { + fprintf(stderr, "-E- Invalid timeout argument: %s.\n", optarg); + return 1; + } if ( timeout_t <= 0 ) { fprintf(stderr, "-E- Wrong timeout, it should be > 0 !\n"); return 1; -- 2.41.0