Re: 2.1.12/2.1.13: #!-scripts do not work as before

Steffen Zahn (zahn@berlin.snafu.de)
Sat, 23 Nov 1996 18:29:43 +0100


Hello,

the following patch fixes the problem of executable scripts with
interpreter and argument like

#!/usr/bin/X11/wishx -f

for me, I tried it with 2.1.13.
Regards
Steffen

_________________________ cut ________________________________
--- linux/fs/binfmt_script.c~ Sat Nov 23 17:04:46 1996
+++ linux/fs/binfmt_script.c Sat Nov 23 18:21:11 1996
@@ -14,7 +14,7 @@
static int do_load_script(struct linux_binprm *bprm,struct pt_regs *regs)
{
char *cp, *i_name, *i_arg;
- char interp[128];
+ char interp[128], *i_start;
int retval;
if ((bprm->buf[0] != '#') || (bprm->buf[1] != '!') || (bprm->sh_bang))
return -ENOEXEC;
@@ -39,9 +39,9 @@
break;
}
for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++);
- if (cp == '\0')
+ if (*cp == '\0')
return -ENOEXEC; /* No interpreter name found */
- strcpy (interp, cp);
+ i_start= cp;
i_name = cp;
i_arg = 0;
for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++) {
@@ -52,6 +52,7 @@
*cp++ = '\0';
if (*cp)
i_arg = cp;
+ strcpy (interp, i_start);
/*
* OK, we've parsed out the interpreter name and
* (optional) argument.
_________________________ cut ________________________________

-- 
work: Steffen.Zahn%robinie@emndev.siemens.co.at | home: zahn@berlin.snafu.de
Any opinions expressed herein are not necessarily those of my employer.
Use of my addresses for unsolicited commercial advertising is forbidden.