This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Patch 1/2] Enhance -s option checking to only accept valid size number
- From: Sunzen Wang <sunzen at gmail dot com>
- To: systemtap at sources dot redhat dot com
- Date: Tue, 19 May 2009 09:07:11 +0800
- Subject: [Patch 1/2] Enhance -s option checking to only accept valid size number
Fix: Enhance -s option checking to only accept valid size number
---
diff --git a/main.cxx b/main.cxx
index 39d835d..ec5506f 100644
--- a/main.cxx
+++ b/main.cxx
@@ -626,8 +626,8 @@ main (int argc, char * const argv [])
break;
case 's':
- s.buffer_size = atoi (optarg);
- if (s.buffer_size < 1 || s.buffer_size > 4095)
+ s.buffer_size = (int) strtoul (optarg, &num_endptr, 10);
+ if (*num_endptr != '\0' || s.buffer_size < 1 || s.buffer_size > 4095)
{
cerr << "Invalid buffer size (should be 1-4095)." << endl;
usage (s, 1);
---
--
sunzen
<<freedom & enjoyment>>