summaryrefslogtreecommitdiffstats
path: root/main.cxx
diff options
context:
space:
mode:
authordsmith <dsmith>2007-03-29 16:17:12 +0000
committerdsmith <dsmith>2007-03-29 16:17:12 +0000
commit3b942fed99d5b54244e1874d18c30457280382ae (patch)
tree1edc8405952f520a7ffbca64f26caa8161f53673 /main.cxx
parent90f98cc36060df795f79379e512d151d0e7c74a4 (diff)
downloadsystemtap-steved-3b942fed99d5b54244e1874d18c30457280382ae.tar.gz
systemtap-steved-3b942fed99d5b54244e1874d18c30457280382ae.tar.xz
systemtap-steved-3b942fed99d5b54244e1874d18c30457280382ae.zip
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].
Diffstat (limited to 'main.cxx')
-rw-r--r--main.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/main.cxx b/main.cxx
index e2226e48..b15c9185 100644
--- 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;