From c897e941ca645ab1e2aa325e5feaae30cc43060e Mon Sep 17 00:00:00 2001 From: Sunzen Wang Date: Tue, 19 May 2009 09:11:01 +0800 Subject: [PATCH] Enhance -x option checking to only accept valid pid Fix: Enhance -x option checking to only accept valid pid --- main.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.cxx b/main.cxx index ec5506f56..1f4f9812d 100644 --- a/main.cxx +++ b/main.cxx @@ -639,7 +639,12 @@ main (int argc, char * const argv []) break; case 'x': - s.target_pid = atoi(optarg); + s.target_pid = (int) strtoul(optarg, &num_endptr, 10); + if (*num_endptr != '\0') + { + cerr << "Invalid target process ID number." << endl; + usage (s, 1); + } break; case 'D': -- 2.43.5