]> sourceware.org Git - systemtap.git/commitdiff
2007-03-29 David Smith <dsmith@redhat.com>
authordsmith <dsmith>
Thu, 29 Mar 2007 16:17:12 +0000 (16:17 +0000)
committerdsmith <dsmith>
Thu, 29 Mar 2007 16:17:12 +0000 (16:17 +0000)
PR 4281
* main.cxx (main): Validates '-m NAME' option.  Chops off '.ko' if
present.  Makes sure name isn't empty.  Makes sure name is only
composed of characters [_a-zA-Z0-9].

ChangeLog
main.cxx

index c2d241556b7fbf3c2498f8c7140edc769e13e655..10c4cc076f511ed138b0ccd4126c4db351fae69b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-03-29  David Smith  <dsmith@redhat.com>
+
+       PR 4281
+       * main.cxx (main): Validates '-m NAME' option.  Chops off '.ko' if
+       present.  Makes sure name isn't empty.  Makes sure name is only
+       composed of characters [_a-zA-Z0-9].
+
 2007-03-28  David Smith  <dsmith@redhat.com>
 
        PR 2341 (partial fix)
index e2226e48f58ee30482a2c11dbed588078a9c35ad..b15c9185610fb3856d2ff80d6fdf6f067939f57b 100644 (file)
--- a/main.cxx
+++ b/main.cxx
@@ -320,6 +320,38 @@ main (int argc, char * const argv [])
 
         case 'm':
           s.module_name = string (optarg);
+         {
+           string::size_type len = s.module_name.length();
+
+           // If the module name ends with '.ko', chop it off since
+           // modutils doesn't like modules named 'foo.ko.ko'.
+           if (len > 3 && s.module_name.substr(len - 3, 3) == ".ko")
+             {
+               s.module_name.erase(len - 3);
+               len -= 3;
+               cerr << "Truncating module name to '" << s.module_name
+                    << "'" << endl;
+             }
+
+           // Make sure an empty module name wasn't specified (-m "")
+           if (len == 0)
+           {
+               cerr << "Module name cannot be empty." << endl;
+               usage (s, 1);
+           }
+
+           // Make sure the module name is only composed of the
+           // following chars: [_a-zA-Z0-9]
+           const string identchars("_" "abcdefghijklmnopqrstuvwxyz"
+                                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789");
+           if (s.module_name.find_first_not_of(identchars) != string::npos)
+             {
+               cerr << "Invalid module name (must only be composed of"
+                   " characters [_a-zA-Z0-9])." << endl;
+               usage (s, 1);
+             }
+         }
+
          cerr << "Warning: using '-m' disables cache support." << endl;
          s.use_cache = false;
           break;
This page took 0.032182 seconds and 5 git commands to generate.