lkml.org 
[lkml]   [2015]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: string_escape_mem ESCAPE_SPACE
From
On Thu, Jul 23, 2015 at 1:27 PM, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Thu, 2015-07-23 at 12:59 -0700, Kees Cook wrote:
>> Hi,
>>
>> I'm curious why ESCAPE_SPACE doesn't escape spaces (0x20)?
>
> Space is a printable character.
> You perhaps wants something like ESCAPE_SPACE | ESCAPE_HEX.

Yeah, I can get the effect I want with:

flags = ESCAPE_SPACE | ESCAPE_SPECIAL | ESCAPE_NULL | ESCAPE_HEX;
esc = "\f\n\r\t\v\\\a\e\0 ";

This isn't reachable via kasprintf, though (it always has a NULL esc).
I will consider some options and send patches.

>> That is
>> surprising to me, especially since things like isspace() include
>> 0x20.
>
> Moreover, there are test cases in test-string_helpers.c module and they
> are based on the real use cases (before helpers were introduced and
> users were converted). So, there is no user which expects hex conversio
> n of the printable character if not asked explicitly.

Yeah, I saw it was testing for space to be excluded. I guess I just
think the name "ESCAPE_SPACE" is misleading. :)

Thanks!

-Kees

--
Kees Cook
Chrome OS Security


\
 
 \ /
  Last update: 2015-07-23 23:01    [W:2.283 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site