summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorPavel Kotucek <pkotucek@cisco.com>2016-10-14 10:20:59 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-10-17 12:17:39 +0000
commita6b31779f56f2b0b538b8e7591e62c545d5a05d8 (patch)
treee85c20b74dd99421d8d101504a66eb980e8323a1 /vnet
parentcfcf1e2c45d1f5da99f416e47c33031e573fecb6 (diff)
VPP-492: Fix ability to change mac address of the interface
Fixed Coverity complaining about the clib_memcpy used in /vnet/vnet/interface.c Change-Id: I401f05aea1066d829abac1555021e1180b4a161e Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/interface.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/vnet/vnet/interface.c b/vnet/vnet/interface.c
index 941ab170..37951c71 100644
--- a/vnet/vnet/interface.c
+++ b/vnet/vnet/interface.c
@@ -1272,8 +1272,11 @@ vnet_hw_interface_change_mac_address_helper (vnet_main_t * vnm,
ethernet_interface_t *ei =
pool_elt_at_index (em->interfaces, hi->hw_instance);
- clib_memcpy (hi->hw_address, (u8 *) & mac_address,
- sizeof (hi->hw_address));
+ vec_validate (hi->hw_address,
+ STRUCT_SIZE_OF (ethernet_header_t, src_address) - 1);
+ clib_memcpy (hi->hw_address, &mac_address,
+ vec_len (hi->hw_address));
+
clib_memcpy (ei->address, (u8 *) & mac_address,
sizeof (ei->address));
ethernet_arp_change_mac (vnm, hw_if_index);