Re: [PATCH] exec: refactor an invalid executable check to use isprint
From: Al Viro
Date: Fri Nov 15 2024 - 13:14:13 EST
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').