lkml.org 
[lkml]   [2013]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] lib/vsprintf: add %pT[C012] format specifier
From
Date
Joe Perches wrote:
> On Sat, 2013-12-28 at 12:08 -0800, Andrew Morton wrote:
> > On Sat, 28 Dec 2013 11:53:25 -0800 Joe Perches <joe@perches.com> wrote:
> >
> > > > > #define PRINTK_PID "\002"
> > > > > #define PRINTK_TASK_ID "\003" /* "comm:pid" */
>
> > > > >
> > > > > printk(PRINTK_TASK_ID ": hair on fire\n");
> > > > >
> > > > > It's certainly compact. I doubt if there's any existing code which
> > > > > deliberately prints control chars?

What about using bytes from \x7F to \xFF ?

We are not passing multibyte characters like UTF-8 in the format string (are
we?) because the non-first byte of multibyte characters by error matching %
will cause security problem (format string bug) because the format string is
parsed as char array.

Then, we could do something like below.

pr_info("%s", current->comm); => pr_info("\x7F\x80");
pr_info("%d", current->pid); => pr_info("\x7F\x81");
pr_info("%10d", current->pid); => pr_info("\x7F10\x81");

If precision field support is unnecessary, we could use only \x80 to \xFF .

pr_info("%s", current->comm); => pr_info("\x80");
pr_info("%d", current->pid); => pr_info("\x81");


\
 
 \ /
  Last update: 2013-12-29 02:21    [W:0.665 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site