aboutsummaryrefslogtreecommitdiffstats
path: root/epan/address_types.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2016-08-26 08:53:33 +0200
committerMichael Mann <mmann78@netscape.net>2016-08-26 16:49:57 +0000
commitd0565ad22b14eae64776fb7cf04377e902380ef9 (patch)
tree36efcbe3cf6e47c9efaee0d578fb3cdb49d2291a /epan/address_types.c
parent18e1ee7160ff4c77b1cb4dfea2c58890807cb715 (diff)
Properly end address type search by name (CID-1362742)
Search address type by name iterates over an array, but fails to find its end. Therefore it may dereference invalid pointers, or NULL. Add the proper check in the for loop and make sure an end condition is always there in the array searched. Change-Id: I60ade9d438dc394340b6483b4fcb23e5ce432000 Reviewed-on: https://code.wireshark.org/review/17337 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/address_types.c')
-rw-r--r--epan/address_types.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/epan/address_types.c b/epan/address_types.c
index cd8440fa06..56e9d227e6 100644
--- a/epan/address_types.c
+++ b/epan/address_types.c
@@ -53,7 +53,7 @@ static int num_dissector_addr_type;
static address_type_t dissector_type_addresses[MAX_DISSECTOR_ADDR_TYPE];
/* Keep track of address_type_t's via their id number */
-static address_type_t* type_list[MAX_ADDR_TYPE_VALUE];
+static address_type_t* type_list[MAX_ADDR_TYPE_VALUE + 1];
/*
* If a user _does_ pass in a too-small buffer, this is probably
@@ -125,7 +125,7 @@ int address_type_get_by_name(const char* name)
{
address_type_t** addr;
- for (addr = type_list; addr != NULL; addr++)
+ for (addr = type_list; *addr != NULL; addr++)
{
if (!strcmp((*addr)->name, name))
{
@@ -654,7 +654,7 @@ void address_types_initialize(void)
/* Initialize the type array. This is mostly for handling
"dissector registered" address type range (for NULL checking) */
- memset(type_list, 0, MAX_ADDR_TYPE_VALUE*sizeof(address_type_t*));
+ memset(type_list, 0, (MAX_ADDR_TYPE_VALUE + 1)*sizeof(address_type_t*));
address_type_register(AT_NONE, &none_address );
address_type_register(AT_ETHER, &ether_address );