diff options
Diffstat (limited to 'fs/binfmt_script.c')
-rw-r--r-- | fs/binfmt_script.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c index 7cde3f46ad26..d0078cbb718b 100644 --- a/fs/binfmt_script.c +++ b/fs/binfmt_script.c | |||
@@ -42,10 +42,14 @@ static int load_script(struct linux_binprm *bprm) | |||
42 | fput(bprm->file); | 42 | fput(bprm->file); |
43 | bprm->file = NULL; | 43 | bprm->file = NULL; |
44 | 44 | ||
45 | bprm->buf[BINPRM_BUF_SIZE - 1] = '\0'; | 45 | for (cp = bprm->buf+2;; cp++) { |
46 | if ((cp = strchr(bprm->buf, '\n')) == NULL) | 46 | if (cp >= bprm->buf + BINPRM_BUF_SIZE) |
47 | cp = bprm->buf+BINPRM_BUF_SIZE-1; | 47 | return -ENOEXEC; |
48 | if (!*cp || (*cp == '\n')) | ||
49 | break; | ||
50 | } | ||
48 | *cp = '\0'; | 51 | *cp = '\0'; |
52 | |||
49 | while (cp > bprm->buf) { | 53 | while (cp > bprm->buf) { |
50 | cp--; | 54 | cp--; |
51 | if ((*cp == ' ') || (*cp == '\t')) | 55 | if ((*cp == ' ') || (*cp == '\t')) |