bridgeif: sanity-check init_data->max_ports <= BRIDGEIF_MAX_PORTS

This commit is contained in:
goldsimon 2017-04-04 22:12:38 +02:00
parent 77df9ccd5a
commit 9c78909857
2 changed files with 4 additions and 0 deletions

View File

@ -69,6 +69,8 @@
/** BRIDGEIF_MAX_PORTS: this is used to create a typedef used for forwarding
* bit-fields: the number of bits required is this + 1 (for the internal/cpu port)
* (63 is the maximum, resulting in an u64_t for the bit mask)
* ATTENTION: this controls the maximum number of the implementation only!
* The max. number of ports per bridge must still be passed via netif_add parameter!
*/
#ifndef BRIDGEIF_MAX_PORTS
#define BRIDGEIF_MAX_PORTS 7

View File

@ -608,6 +608,8 @@ bridgeif_init(struct netif *netif)
init_data = (bridgeif_initdata_t *)netif->state;
LWIP_ASSERT("init_data != NULL", (init_data != NULL));
LWIP_ASSERT("init_data->max_ports <= BRIDGEIF_MAX_PORTS",
init_data->max_ports <= BRIDGEIF_MAX_PORTS);
alloc_len = sizeof(bridgeif_private_t) + (init_data->max_ports*sizeof(bridgeif_port_t) + (init_data->max_fdb_static_entries*sizeof(bridgeif_fdb_static_entry_t)));
LWIP_DEBUGF(BRIDGEIF_DEBUG, ("bridgeif_init: allocating %d bytes for private data\n", (int)alloc_len));