[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 1/6] json: Fix lexer for lookahead character beyond '
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 1/6] json: Fix lexer for lookahead character beyond '\x7F' |
Date: |
Mon, 24 Sep 2018 18:20:02 +0200 |
The lexer fails to end a valid token when the lookahead character is
beyond '\x7F'. For instance, input
true\xC2\xA2
produces the tokens
JSON_ERROR true\xC2
JSON_ERROR \xA2
This should be
JSON_KEYWORD true
JSON_ERROR \xC2
JSON_ERROR \xA2
instead.
The culprit is
#define TERMINAL(state) [0 ... 0x7F] = (state)
It leaves [0x80..0xFF] zero, i.e. IN_ERROR. Has always been broken.
Fix it to initialize the complete array.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
---
qobject/json-lexer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c
index e1745a3d95..4867839f66 100644
--- a/qobject/json-lexer.c
+++ b/qobject/json-lexer.c
@@ -123,7 +123,7 @@ enum json_lexer_state {
QEMU_BUILD_BUG_ON((int)JSON_MIN <= (int)IN_START_INTERP);
QEMU_BUILD_BUG_ON(IN_START_INTERP != IN_START + 1);
-#define TERMINAL(state) [0 ... 0x7F] = (state)
+#define TERMINAL(state) [0 ... 0xFF] = (state)
/* Return whether TERMINAL is a terminal state and the transition to it
from OLD_STATE required lookahead. This happens whenever the table
--
2.17.1
- [Qemu-devel] [PULL 0/6] QObject patches for 2018-09-24, Markus Armbruster, 2018/09/24
- [Qemu-devel] [PULL 1/6] json: Fix lexer for lookahead character beyond '\x7F',
Markus Armbruster <=
- [Qemu-devel] [PULL 6/6] json: Eliminate lexer state IN_WHITESPACE, pseudo-token JSON_SKIP, Markus Armbruster, 2018/09/24
- [Qemu-devel] [PULL 4/6] json: Nicer recovery from lexical errors, Markus Armbruster, 2018/09/24
- [Qemu-devel] [PULL 2/6] json: Clean up how lexer consumes "end of input", Markus Armbruster, 2018/09/24
- [Qemu-devel] [PULL 5/6] json: Eliminate lexer state IN_ERROR, Markus Armbruster, 2018/09/24
- [Qemu-devel] [PULL 3/6] json: Make lexer's "character consumed" logic less confusing, Markus Armbruster, 2018/09/24
- Re: [Qemu-devel] [PULL 0/6] QObject patches for 2018-09-24, Peter Maydell, 2018/09/25