projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
23e93c9
)
Revert "exec: load_script: don't blindly truncate shebang string"
author
Linus Torvalds
<
[email protected]
>
Thu, 14 Feb 2019 23:02:18 +0000
(15:02 -0800)
committer
Linus Torvalds
<
[email protected]
>
Thu, 14 Feb 2019 23:02:18 +0000
(15:02 -0800)
This reverts commit
8099b047ecc431518b9bb6bdbba3549bbecdc343
.
It turns out that people do actually depend on the shebang string being
truncated, and on the fact that an interpreter (like perl) will often
just re-interpret it entirely to get the full argument list.
Reported-by: Samuel Dionne-Riel <
[email protected]
>
Acked-by: Kees Cook <
[email protected]
>
Cc: Oleg Nesterov <
[email protected]
>
Signed-off-by: Linus Torvalds <
[email protected]
>
fs/binfmt_script.c
patch
|
blob
|
history
diff --git
a/fs/binfmt_script.c
b/fs/binfmt_script.c
index d0078cbb718b4855dc520dbfae91223d499da81a..7cde3f46ad263ab084aafaefa14161902f33d4f1 100644
(file)
--- a/
fs/binfmt_script.c
+++ b/
fs/binfmt_script.c
@@
-42,14
+42,10
@@
static int load_script(struct linux_binprm *bprm)
fput(bprm->file);
bprm->file = NULL;
- for (cp = bprm->buf+2;; cp++) {
- if (cp >= bprm->buf + BINPRM_BUF_SIZE)
- return -ENOEXEC;
- if (!*cp || (*cp == '\n'))
- break;
- }
+ bprm->buf[BINPRM_BUF_SIZE - 1] = '\0';
+ if ((cp = strchr(bprm->buf, '\n')) == NULL)
+ cp = bprm->buf+BINPRM_BUF_SIZE-1;
*cp = '\0';
-
while (cp > bprm->buf) {
cp--;
if ((*cp == ' ') || (*cp == '\t'))