[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apparmor-dev
Subject:    Re: [apparmor] [patch][parser] Fix the processing of character escape sequences
From:       John Johansen <john.johansen () canonical ! com>
Date:       2014-06-19 20:38:43
Message-ID: 53A34A53.5090900 () canonical ! com
[Download RAW message or body]

On 06/19/2014 01:37 PM, Steve Beattie wrote:
> On Thu, Jun 19, 2014 at 12:34:42PM -0700, Steve Beattie wrote:
>> On Thu, Jun 19, 2014 at 10:52:49AM -0700, John Johansen wrote:
>>> Fix the processing of character escape sequences
>>>
>>> r2456 unified escape sequence processing but it results in the \\
>>> sequence being processed multiple times (lexer, regex conversion,
>>> backend pcre parsing).
>>>
>>> What used to happen was the lexer would only convert octal sequences
>>> and a few special escapes, \\ would be passed through the lexer and
>>> the regex conversion, thus only being handled in the pcre backend.
>>>
>>> r2456 changed that so that \\ is handled by the lexer, converting it
>>> to \, which is handled as an escape sequence in both the regex
>>> conversion and the pcre backend.
>>>
>>> This means
>>>   \\001 instead of being treated as the literal \001 is treated
>>>   as an octal escape sequence which is rejected by the regex conversion
>>>   (it only allows for certain special chars).
>>>
>>>   etc.
>>>
>>> Fix this by ensuring the lexer does not processes \\ and passes it
>>> through so it is only handled in the backend as was done in the past.
>>>
>>> Also fix front end escape sequence processing of octals etc from resulting
>>> in a later escape sequence.  That is \134, \d92, .. would get converted
>>> to \ in the lexer and then treated as an escape sequence in the regex
>>> conversion or pcre processing.
>>>
>>> We fix this by converting them to the equivalent \\ sequence in the
>>> lexer and letting the backend processes it.
>>>
>>> Signed-off-by: John Johansen <john.johansen@canonical.com>
>> Acked-by: Steve Beattie <steve@nxnw.org>
> 
> Actually, this needs a corresponding fixup in the parser unit tests:
> 
> Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>

> ---
>  parser/parser_misc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: b/parser/parser_misc.c
> ===================================================================
> --- a/parser/parser_misc.c
> +++ b/parser/parser_misc.c
> @@ -1351,7 +1351,7 @@ int test_processquoted(void)
>  	free(out);
>  
>  	teststring = "\"a\\\\bcdefg\"";
> -	processedstring = "a\\bcdefg";
> +	processedstring = "a\\\\bcdefg";
>  	out = processquoted(teststring, strlen(teststring));
>  	MY_TEST(strcmp(processedstring, out) == 0,
>  			"processquoted on quoted slash");
> 
> 
> 
> 


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/apparmor
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic