[kernel-hardening] Re: [PATCH] kernel: escape non-ASCII and control characters in printk()

Vasiliy Kulikov
2011-06-22T17:48:12Z

On Wed, Jun 22, 2011 at 10:14 -0700, Joe Perches wrote:
> On Wed, 2011-06-22 at 20:53 +0400, Vasiliy Kulikov wrote:
> > On Wed, Jun 22, 2011 at 09:38 -0700, Joe Perches wrote:
> > > > + if ((c >= ' ' && c < 127) || c == '\n')
> > > if (isprint(c))
> > #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0)
> > It slightly differs from what I've written. It (1) lacks '\n',
>
> You still need tab,

Correct.

> so:
>
> if (isprint(c) || isspace(c))

No, it also allows vertical tabs. Looking into __ctype only ' ', '\n' and
'\t' should be allowed among all _S, so

if (isprint(c) || (c == '\n') || (c == '\t'))

Thanks,

--
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments