diff options
author | Sunzen Wang <sunzen@gmail.com> | 2009-05-18 20:38:02 +0800 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2009-05-19 14:48:52 +0200 |
commit | 877bbb205c95b273ea0d68f184cdda15acc08875 (patch) | |
tree | edeb1d1d8ed3e841efee1a7caba7c82442f2595f /main.cxx | |
parent | 9d6253e9a0082b220c395b372af8437ffccdccda (diff) | |
download | systemtap-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.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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); |