[LTP] [PATCH v2 12/15] ujson: reader: Reject \u0000 escape in strings
Andrea Cervesato
andrea.cervesato@suse.de
Tue Oct 13 14:02:08 CEST 2026
From: Andrea Cervesato <andrea.cervesato@suse.com>
String values and object IDs are returned as NUL-terminated C strings.
A \u0000 escape was written as a NUL byte into the output buffer,
silently truncating the string. Report an error instead.
Fixes: c50a0e0751c8 ("libs: Vendor ujson library")
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
libs/ujson/ujson_reader.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libs/ujson/ujson_reader.c b/libs/ujson/ujson_reader.c
index 9d17bbf4b..dae45ebb9 100644
--- a/libs/ujson/ujson_reader.c
+++ b/libs/ujson/ujson_reader.c
@@ -135,6 +135,12 @@ static unsigned int parse_ucode_esc(ujson_reader *buf, char *str,
if (ucode < 0)
return 0;
+ /* Strings are NUL-terminated, an embedded NUL would truncate them */
+ if (!ucode) {
+ ujson_err(buf, "\\u0000 is not supported");
+ return 0;
+ }
+
if (ucode >= 0xdc00 && ucode <= 0xdfff) {
ujson_err(buf, "Unpaired low surrogate");
return 0;
--
2.51.0
More information about the ltp
mailing list