aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2017-10-04 08:12:23 +0200
committerMichael Mann <mmann78@netscape.net>2017-10-04 12:09:55 +0000
commit1961297a55f0b7a2ff6acc1ab7909d50e4b80f70 (patch)
treea7845675d5277ef2191e59383fab4e0b879f1f8a
parentea6e4b577f08f88e0d5cabb7cb38e17b236e513a (diff)
sharkd: check if JSON value is string or primitive (true/false/null/number).
Add extra check for token type, previously it was possible to pass for example: {"columns":["one","two","three"]}. Such format is not supported. Change-Id: I6ac2e3ca9eba868cd72ed886ad40745ebbc43d73 Reviewed-on: https://code.wireshark.org/review/23834 Petri-Dish: Jakub Zawadzki <darkjames-ws@darkjames.pl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
-rw-r--r--sharkd_session.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sharkd_session.c b/sharkd_session.c
index ee71e16..f7d6c5a 100644
--- a/sharkd_session.c
+++ b/sharkd_session.c
@@ -3861,13 +3861,19 @@ sharkd_session_process(char *buf, const jsmntok_t *tokens, int count)
return;
}
+ if (tokens[i + 1].type != JSMN_STRING && tokens[i + 1].type != JSMN_PRIMITIVE)
+ {
+ fprintf(stderr, "sanity check(3a): [%d] wrong type\n", i + 1);
+ return;
+ }
+
buf[tokens[i + 0].end] = '\0';
buf[tokens[i + 1].end] = '\0';
/* unescape only value, as keys are simple strings */
- if (!json_unescape_str(&buf[tokens[i + 1].start]))
+ if (tokens[i + 1].type == JSMN_STRING && !json_unescape_str(&buf[tokens[i + 1].start]))
{
- fprintf(stderr, "sanity check(3a): [%d] cannot unescape string\n", i + 1);
+ fprintf(stderr, "sanity check(3b): [%d] cannot unescape string\n", i + 1);
return;
}
}