public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Patch 1/2] Enhance -s option checking to only accept valid size   number
@ 2009-05-19  1:07 Sunzen Wang
  0 siblings, 0 replies; only message in thread
From: Sunzen Wang @ 2009-05-19  1:07 UTC (permalink / raw)
  To: systemtap

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-05-19  1:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-19  1:07 [Patch 1/2] Enhance -s option checking to only accept valid size number Sunzen Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).