forked from osmocom/wireshark
Bug fix in json dissector that made the heuristic fail.
Change-Id: Iff53cfd8fd9d760b04c638c87f8a44587b268cd7 Reviewed-on: https://code.wireshark.org/review/6674 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
11e557a794
commit
1af7b97927
|
@ -572,15 +572,17 @@ static void init_json_parser(void) {
|
||||||
static gboolean
|
static gboolean
|
||||||
dissect_json_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
dissect_json_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
|
||||||
{
|
{
|
||||||
|
/* We expect no more than 1024 tokens */
|
||||||
|
const guint max_tokens = 1024;
|
||||||
guint len = tvb_captured_length(tvb);
|
guint len = tvb_captured_length(tvb);
|
||||||
guint8* buf = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, len, ENC_ASCII);
|
guint8* buf = tvb_get_string_enc(wmem_packet_scope(), tvb, 0, len, ENC_ASCII);
|
||||||
|
|
||||||
jsmn_parser p;
|
jsmn_parser p;
|
||||||
/* We expect no more than 1024 tokens */
|
|
||||||
jsmntok_t* t = (jsmntok_t*)wmem_alloc_array(wmem_packet_scope(), jsmntok_t, 1024);
|
jsmntok_t* t = (jsmntok_t*)wmem_alloc_array(wmem_packet_scope(), jsmntok_t, max_tokens);
|
||||||
|
|
||||||
jsmn_init(&p);
|
jsmn_init(&p);
|
||||||
if (jsmn_parse(&p, buf, len, t, sizeof(t)/sizeof(t[0])) < 0) {
|
if (jsmn_parse(&p, buf, len, t, max_tokens) < 0) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return (dissect_json(tvb, pinfo, tree, data) != 0);
|
return (dissect_json(tvb, pinfo, tree, data) != 0);
|
||||||
|
|
Loading…
Reference in New Issue