Re: binfmt_script

Peter (peter@fido.bfriars.ox.ac.uk)
Wed, 17 Jun 1998 17:28:08 +0100


Does this patch fix the problem? (Works for me). It's against 2.1.106.
If you're patching 2.0.34, the first hunk will fail, but it should be
obvious what needs doing.

Can anyone comment on whether this is the Right Thing (TM) to do?

Regards,

Peter

--- binfmt_script.c.old Wed Jun 17 15:54:48 1998
+++ binfmt_script.c Wed Jun 17 16:59:35 1998
@@ -14,7 +14,7 @@

static int do_load_script(struct linux_binprm *bprm,struct pt_regs
*regs)
{
- char *cp, *i_name, *i_name_start, *i_arg;
+ char *cp, *i_name, *i_name_start, *i_arg, *end;
struct dentry * dentry;
char interp[128];
int retval;
@@ -41,6 +41,7 @@
else
break;
}
+ end = cp;
for (cp = bprm->buf+2; (*cp == ' ') || (*cp == '\t'); cp++);
if (*cp == '\0')
return -ENOEXEC; /* No interpreter name found */
@@ -69,8 +70,17 @@
bprm->p = copy_strings(1, &bprm->filename, bprm->page, bprm->p, 2);
bprm->argc++;
if (i_arg) {
- bprm->p = copy_strings(1, &i_arg, bprm->page, bprm->p, 2);
- bprm->argc++;
+ cp = end;
+ while (cp>i_arg) {
+ for (; (cp>=i_arg) && (*cp != ' ') && (*cp != '\t'); cp--);
+ cp++;
+ bprm->p = copy_strings(1, &cp, bprm->page, bprm->p, 2);
+ bprm->argc++;
+ if (cp>i_arg) {
+ *(--cp) = 0;
+ cp--;
+ }
+ }
}
bprm->p = copy_strings(1, &i_name, bprm->page, bprm->p, 2);
bprm->argc++;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu