[PATCH] src/utilities/kernelscan: fix parsing of escaped C strings
Colin King
colin.king at canonical.com
Sat Jun 4 16:47:55 UTC 2016
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);
}
--
2.8.1
More information about the fwts-devel
mailing list