Re: [PATCH] exec/binfmt_script: trip zero bytes from the buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Andrei Vagin <avagin@xxxxxxxxx> writes:

> Without this fix, if we try to run a script that contains only the
> interpreter line, the interpreter is executed with one extra empty
> argument.
>
> The code is written so that i_end has to be set to the end of valuable
> data in the buffer.

Out of curiosity how did you spot this change in behavior?

> Fixes: ccbb18b67323 ("exec/binfmt_script: Don't modify bprm->buf and then return -ENOEXEC")
> Cc: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
> Signed-off-by: Andrei Vagin <avagin@xxxxxxxxx>
> ---
>  fs/binfmt_script.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/fs/binfmt_script.c b/fs/binfmt_script.c
> index 1b6625e95958..e242680f96e1 100644
> --- a/fs/binfmt_script.c
> +++ b/fs/binfmt_script.c
> @@ -68,6 +68,9 @@ static int load_script(struct linux_binprm *bprm)
>  		if (!next_terminator(i_end, buf_end))
>  			return -ENOEXEC;
>  		i_end = buf_end;
> +		/* Trim zero bytes from i_end */
> +		while (i_end[-1] == 0)
> +			i_end--;
>  	}
>  	/* Trim any trailing spaces/tabs from i_end */
>  	while (spacetab(i_end[-1]))



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux