[Patch 1/2] Enhance -s option checking to only accept valid size number
Sunzen Wang
sunzen@gmail.com
Tue May 19 01:07:00 GMT 2009
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>>
More information about the Systemtap
mailing list