summaryrefslogtreecommitdiffstats
path: root/main.cxx
diff options
context:
space:
mode:
authorSunzen Wang <sunzen@gmail.com>2009-05-18 20:38:02 +0800
committerMark Wielaard <mjw@redhat.com>2009-05-19 14:48:52 +0200
commit877bbb205c95b273ea0d68f184cdda15acc08875 (patch)
treeedeb1d1d8ed3e841efee1a7caba7c82442f2595f /main.cxx
parent9d6253e9a0082b220c395b372af8437ffccdccda (diff)
downloadsystemtap-steved-877bbb205c95b273ea0d68f184cdda15acc08875.tar.gz
systemtap-steved-877bbb205c95b273ea0d68f184cdda15acc08875.tar.xz
systemtap-steved-877bbb205c95b273ea0d68f184cdda15acc08875.zip
Fix: Enhance -p option checking so as to just accept valid number
Diffstat (limited to 'main.cxx')
-rw-r--r--main.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/main.cxx b/main.cxx
index 1ac5dd5a..39d835d7 100644
--- a/main.cxx
+++ b/main.cxx
@@ -469,6 +469,7 @@ main (int argc, char * const argv [])
while (true)
{
int long_opt;
+ char * num_endptr;
#define LONG_OPT_KELF 1
#define LONG_OPT_KMAP 2
#define LONG_OPT_IGNORE_VMLINUX 3
@@ -518,8 +519,8 @@ main (int argc, char * const argv [])
cerr << "Listing (-l) mode implies pass 2." << endl;
usage (s, 1);
}
- s.last_pass = atoi (optarg);
- if (s.last_pass < 1 || s.last_pass > 5)
+ s.last_pass = (int)strtoul(optarg, &num_endptr, 10);
+ if (*num_endptr != '\0' || s.last_pass < 1 || s.last_pass > 5)
{
cerr << "Invalid pass number (should be 1-5)." << endl;
usage (s, 1);