lkml.org 
[lkml]   [2011]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH/RFC] Treat CR like NL in script interpreter line
Date
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

\
 
 \ /
  Last update: 2011-02-17 21:07    [W:0.153 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site