diff options
author | Ron Yorston <rmy@pobox.com> | 2019-05-03 09:34:55 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-05-03 09:34:55 +0100 |
commit | 03a7b173605a890e1db5177ecd5b8dd591081c41 (patch) | |
tree | 9b50ae94762cf0ebd07cd96a5705c718156dd54d | |
parent | ee3d2805065f09b3d5d28e3518f1351b5d1c0bf7 (diff) | |
download | busybox-w32-03a7b173605a890e1db5177ecd5b8dd591081c41.tar.gz busybox-w32-03a7b173605a890e1db5177ecd5b8dd591081c41.tar.bz2 busybox-w32-03a7b173605a890e1db5177ecd5b8dd591081c41.zip |
win32: trim leading and trailing spaces from shebang options
Commit 97e2c4a05 (win32: changes to treatment of scripts) attempted
to use strtok(3) to simplify the parsing of shebang lines.
Unfortunately it resulted in leading and trailing whitespace being
left in the option string. Fix this by trimming the options before
they're returned.
Reported-by: Niklas DAHLQUIST <niklas.dahlquist@st.com>
Signed-off-by: Ron Yorston <rmy@pobox.com>
-rw-r--r-- | win32/process.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/win32/process.c b/win32/process.c index 99db6f79f..8546c6e2f 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -64,6 +64,10 @@ parse_interpreter(const char *cmd, interp_t *interp) | |||
64 | interp->path = path; | 64 | interp->path = path; |
65 | interp->name = t; | 65 | interp->name = t; |
66 | interp->opts = strtok(NULL, "\r\n"); | 66 | interp->opts = strtok(NULL, "\r\n"); |
67 | /* Trim leading and trailing whitespace from the options. | ||
68 | * If the resulting string is empty return a NULL pointer. */ | ||
69 | if (interp->opts && trim(interp->opts) == interp->opts) | ||
70 | interp->opts = NULL; | ||
67 | return 1; | 71 | return 1; |
68 | } | 72 | } |
69 | 73 | ||