This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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>>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]