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 2/2] Enhance -x option checking to only accept valid pid


Fix: Enhance -x option checking to only accept valid pid
---
diff --git a/main.cxx b/main.cxx
index ec5506f..dda781d 100644
--- a/main.cxx
+++ b/main.cxx
@@ -639,7 +639,12 @@ main (int argc, char * const argv [])
 	  break;

 	case 'x':
-	  s.target_pid = atoi(optarg);
+	  s.target_pid = (int) strtoul(optarg, &num_endptr, 10);
+	  if (*num_endptr != '\0')
+	    {
+	      cerr << "Invalid target process ID number." << endl;
+	      usage (s, 1);
+	    }
 	  break;

 	case 'D':
---

Thanks.
-- 
sunzen
<<freedom & enjoyment>>


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