From 7f0ff9143159cfa76408ed3dfedb2d730b17fb46 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 1 Apr 2021 10:33:05 +0200 Subject: lib: allow parsing non-array, non-object value in json() Signed-off-by: Jo-Philipp Wich --- lib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 23141a3..ea48e34 100644 --- a/lib.c +++ b/lib.c @@ -2053,7 +2053,10 @@ uc_json(uc_vm *vm, size_t nargs) str = json_object_get_string(src); len = json_object_get_string_len(src); - rv = json_tokener_parse_ex(tok, str, len); + /* NB: the len + 1 here is intentional to pass the terminating \0 byte + * to the json-c parser. This is required to work-around upstream + * issue #681 */ + rv = json_tokener_parse_ex(tok, str, len + 1); err = json_tokener_get_error(tok); if (err == json_tokener_continue) { -- cgit v1.2.3