proto: Check for empty protocol->fields

In proto_get_first_protocol_field() we must check for an empty
protocol->fields because Lua scripts may have protocols without
fields and g_ptr_array_index() does not perform bounds checking
on the given index.

Bug: 13223
Change-Id: Ib2f6286d0799541243450348dcf345a965b2825c
Reviewed-on: https://code.wireshark.org/review/20455
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Stig Bjørlykke 2017-03-09 08:34:54 +01:00 committed by Anders Broman
parent 540b555729
commit 528a3d31ff
1 changed files with 1 additions and 1 deletions

View File

@ -6066,7 +6066,7 @@ proto_get_first_protocol_field(const int proto_id, void **cookie)
{
protocol_t *protocol = find_protocol_by_id(proto_id);
if ((protocol == NULL) || (protocol->fields == NULL))
if ((protocol == NULL) || (protocol->fields == NULL) || (protocol->fields->len == 0))
return NULL;
*cookie = GUINT_TO_POINTER(0 + 1);