ACK: [PATCH] src/utilities/kernelscan: fix parsing of escaped C strings

Alex Hung alex.hung at canonical.com
Wed Jun 8 00:14:48 UTC 2016


On 2016-06-05 12:47 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Enable correct parsing of escaped C literal strings.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/utilities/kernelscan.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
> index 8b25633..d1bebdd 100644
> --- a/src/utilities/kernelscan.c
> +++ b/src/utilities/kernelscan.c
> @@ -647,8 +647,6 @@ static int parse_identifier(parser *p, token *t, int ch)
>    */
>   static int parse_literal(parser *p, token *t, int literal, token_type type)
>   {
> -	bool escaped = false;
> -
>   	t->type = type;
>
>   	token_append(t, literal);
> @@ -660,16 +658,18 @@ static int parse_literal(parser *p, token *t, int literal, token_type type)
>   		}
>
>   		if (ch == '\\') {
> -			escaped = true;
> +			ch = get_next(p);
> +			if (ch == EOF)
> +				return PARSER_OK;
> +			token_append(t, '\\');
>   			token_append(t, ch);
>   			continue;
>   		}
>
> -		if (!escaped && ch == literal) {
> +		if (ch == literal) {
>   			token_append(t, ch);
>   			return PARSER_OK;
>   		}
> -		escaped = false;
>
>   		token_append(t, ch);
>   	}
>

Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list