提交 cb5b020a 编写于 作者: L Linus Torvalds

Revert "exec: load_script: don't blindly truncate shebang string"

This reverts commit 8099b047.

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: NSamuel Dionne-Riel <samuel@dionne-riel.com>
Acked-by: NKees Cook <keescook@chromium.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 23e93c9b
...@@ -42,14 +42,10 @@ static int load_script(struct linux_binprm *bprm) ...@@ -42,14 +42,10 @@ static int load_script(struct linux_binprm *bprm)
fput(bprm->file); fput(bprm->file);
bprm->file = NULL; bprm->file = NULL;
for (cp = bprm->buf+2;; cp++) { bprm->buf[BINPRM_BUF_SIZE - 1] = '\0';
if (cp >= bprm->buf + BINPRM_BUF_SIZE) if ((cp = strchr(bprm->buf, '\n')) == NULL)
return -ENOEXEC; cp = bprm->buf+BINPRM_BUF_SIZE-1;
if (!*cp || (*cp == '\n'))
break;
}
*cp = '\0'; *cp = '\0';
while (cp > bprm->buf) { while (cp > bprm->buf) {
cp--; cp--;
if ((*cp == ' ') || (*cp == '\t')) if ((*cp == ' ') || (*cp == '\t'))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册