aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-07-13 11:13:29 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-07-13 12:19:11 +0200
commitf8b3091f42a554508600a79d2492ea6368fbd46b (patch)
treeb42b9ac603bc12559a13ae4604fde85954f2d09a
parent22c9883131a8cac3e1fcf2ebf025518e59536ad0 (diff)
afb-wsj1: Fix json parsing of unterminated
When receiving 'false', 'true' or 1, the tokener isn't able to terminate its job without ambiguity. Catch this case to force a terminating character. Change-Id: I5c78f759852060ccf0fac87b3f6fc33a65bf30c9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-wsj1.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/afb-wsj1.c b/src/afb-wsj1.c
index 79cb66e9..466b58ad 100644
--- a/src/afb-wsj1.c
+++ b/src/afb-wsj1.c
@@ -392,6 +392,8 @@ struct json_object *afb_wsj1_msg_object_j(struct afb_wsj1_msg *msg)
pthread_mutex_lock(&msg->wsj1->mutex);
json_tokener_reset(msg->wsj1->tokener);
object = json_tokener_parse_ex(msg->wsj1->tokener, msg->object_s, (int)msg->object_s_length);
+ if (object == NULL && json_tokener_get_error(msg->wsj1->tokener) == json_tokener_continue)
+ object = json_tokener_parse_ex(msg->wsj1->tokener, "", 1);
pthread_mutex_unlock(&msg->wsj1->mutex);
if (object == NULL) {
/* lazy error detection of json request. Is it to improve? */