summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Ch. Eigler <fche@elastic.org>2008-10-15 19:08:45 -0400
committerFrank Ch. Eigler <fche@elastic.org>2008-10-15 19:08:45 -0400
commit927b945c9ab8060f9929ad72ac126b65c8ee49d3 (patch)
treecb432ba8eebfb9c766bf3a3adfe0db1d4d0e6e56
parent42b75235a537bae856b9ec8b763b5ea5369d7b22 (diff)
downloadsystemtap-steved-927b945c9ab8060f9929ad72ac126b65c8ee49d3.tar.gz
systemtap-steved-927b945c9ab8060f9929ad72ac126b65c8ee49d3.tar.xz
systemtap-steved-927b945c9ab8060f9929ad72ac126b65c8ee49d3.zip
fix wordexp error handling, for invalid shell-like stap -c "command > file"
Reported-By: Wade Mealing <wmealing@redhat.com>
-rw-r--r--runtime/staprun/ChangeLog4
-rw-r--r--runtime/staprun/mainloop.c12
2 files changed, 13 insertions, 3 deletions
diff --git a/runtime/staprun/ChangeLog b/runtime/staprun/ChangeLog
index c6d75106..6e8a49f6 100644
--- a/runtime/staprun/ChangeLog
+++ b/runtime/staprun/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-15 Frank Ch. Eigler <fche@elastic.org>
+
+ * mainloop.c (start_cmd): Fix wordexp error handling.
+
2008-09-18 David Smith <dsmith@redhat.com>
PR 6903.
diff --git a/runtime/staprun/mainloop.c b/runtime/staprun/mainloop.c
index 6fc061ae..8db42d7d 100644
--- a/runtime/staprun/mainloop.c
+++ b/runtime/staprun/mainloop.c
@@ -126,9 +126,15 @@ void start_cmd(void)
work well if target_cmd is a shell builtin. We really want to
probe a new child process, not a mishmash of shell-interpreted
stuff. */
- rc = wordexp (target_cmd, & words, WRDE_NOCMD);
- if (rc != 0) { _perr ("wordexp parsing error"); _exit (1); }
- if (words.we_wordc < 1) { _perr ("empty target_cmd"); _exit (1); }
+ rc = wordexp (target_cmd, & words, WRDE_NOCMD|WRDE_UNDEF);
+ switch (rc)
+ {
+ case 0: break;
+ case WRDE_BADCHAR: _err ("wordexp: invalid shell meta-character in -c COMMAND\n"); _exit(1);
+ case WRDE_SYNTAX: _err ("wordexp: syntax error (unmatched quotes?) in -c COMMAND\n"); _exit(1);
+ default: _err ("wordexp: parsing error (%d)\n", rc); _exit (1);
+ }
+ if (words.we_wordc < 1) { _err ("empty -c COMMAND"); _exit (1); }
rc = ptrace (PTRACE_TRACEME, 0, 0, 0);
if (rc < 0) perror ("ptrace me");