Re: [PATCH] exec: refactor an invalid executable check to use isprint

From: Nir Lichtman
Date: Fri Nov 15 2024 - 12:31:03 EST


On Fri, Nov 15, 2024 at 05:04:47PM +0000, Al Viro wrote:
> On Fri, Nov 15, 2024 at 04:53:51PM +0000, Nir Lichtman wrote:
> > Remove private printable macro that is defined in exec.c and migrate to
> > using the public isprint macro instead
>
>
> > -#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
>
> > - if (printable(bprm->buf[0]) && printable(bprm->buf[1]) &&
> > - printable(bprm->buf[2]) && printable(bprm->buf[3]))
> > + if (isprint(bprm->buf[0]) && isprint(bprm->buf[1]) &&
> > + isprint(bprm->buf[2]) && isprint(bprm->buf[3]))
>
> RTFM(isprint). Or run a trivial loop and check what it does, for that
> matter.
>
> isprint('\t') is false. So's isprint('\n').

Right my bad I read _SP as _S by mistake, I'll send out another version with a fix considering the spaces