diff options
author | Steve Shin <jonshin@cisco.com> | 2017-10-25 11:16:45 -0700 |
---|---|---|
committer | John Lo <loj@cisco.com> | 2017-10-25 20:14:01 +0000 |
commit | cda4c88de76fb37105d6bcb7115f5f6fcd107b9b (patch) | |
tree | 5f7c49ebd7990618e1f005fca472bacd6dd5683d | |
parent | 6476b3c1484eed25eeab23774a248a3f8593578e (diff) |
lldp: protection code to check a valid interface index
When lldp interface is set, it's better to check valid interface index.
Change-Id: I0db0ab6483ad73d28c69893576aa9b719c3b087c
Signed-off-by: Steve Shin <jonshin@cisco.com>
-rw-r--r-- | src/vnet/lldp/lldp_cli.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/vnet/lldp/lldp_cli.c b/src/vnet/lldp/lldp_cli.c index ddedd137bed..239a7abe082 100644 --- a/src/vnet/lldp/lldp_cli.c +++ b/src/vnet/lldp/lldp_cli.c @@ -49,9 +49,16 @@ lldp_cfg_intf_set (u32 hw_if_index, u8 ** port_desc, u8 ** mgmt_ip4, lldp_main_t *lm = &lldp_main; vnet_main_t *vnm = lm->vnet_main; ethernet_main_t *em = ðernet_main; - const vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index); - const ethernet_interface_t *eif = ethernet_get_interface (em, hw_if_index); + const vnet_hw_interface_t *hi; + const ethernet_interface_t *eif; + if (pool_is_free_index (vnm->interface_main.hw_interfaces, hw_if_index)) + { + return lldp_invalid_arg; + } + + hi = vnet_get_hw_interface (vnm, hw_if_index); + eif = ethernet_get_interface (em, hw_if_index); if (!eif) { return lldp_not_supported; |