Re: [PATCH v2 2/5] string_helpers: add kstrdup_quotable_cmdline

From: Andy Shevchenko
Date: Wed Mar 30 2016 - 07:10:45 EST


On Wed, 2016-03-30 at 14:07 +0300, Andy Shevchenko wrote:
> On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote:


> > + res = get_cmdline(task, buffer, PAGE_SIZE - 1);
> > + buffer[res] = '\0';
> > +
> > + /* Collapse trailing NULLs. */
> > + for (; res > 0; res--)
> > + if (buffer[res-1] != '\0')
> > + break;
> /* buffer[res] is '\0', so, predecrement is safe here */
> while (buffer[--res] == '\0')
> Â/* nothing */;
>
> ?
>

Oops, no, the following should be better

while (--res >= 0 && buffer[res] == '\0') ;

--
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Intel Finland Oy