Messages in this thread Patch in this message | | | From | Andrew Farmer <> | Subject | [PATCH/RFC] Treat CR like NL in script interpreter line | Date | Thu, 17 Feb 2011 12:04:19 -0800 |
| |
Command-line or CGI scripts with CR+LF line ending end up confusing binfmt_script. This typically ends up making the scripts fail to run with inexplicable error messages (like "no such file or directory"). While it'd certainly be ideal to just tell users to use sensible text editors, making their scripts just work as intended is nice too.
When a similar patch was proposed in 2001, the issue was raised that it would prevent the operation of a script using the "perl\r" interpreter, for instance. However, not only is this a very silly interpreter name, but it's also already impossible to use an interpreter with a tab, space, or newline in its name, and I don't believe anyone's complained about those inabilities!
--- fs/binfmt_script.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c index 396a988..b19c001 100644 --- a/fs/binfmt_script.c +++ b/fs/binfmt_script.c @@ -36,7 +36,7 @@ static int load_script(struct linux_binprm *bprm,struct pt_regs *regs) bprm->file = NULL; bprm->buf[BINPRM_BUF_SIZE - 1] = '\0'; - if ((cp = strchr(bprm->buf, '\n')) == NULL) + if ((cp = strpbrk(bprm->buf, "\n\r")) == NULL) cp = bprm->buf+BINPRM_BUF_SIZE-1; *cp = '\0'; while (cp > bprm->buf) { -- 1.7.1.1
| |