sendarp: fix out of bound read on mac address

mac address is only 6 bytes, which we specify in sll_halen, so do not try to
read more than that into sll_addr.

Reported-by: Coverity#375313
This commit is contained in:
Dominique Martinet 2022-11-05 21:25:31 +09:00
parent af92de5eeb
commit bbedc40bf2

2
arp.c
View file

@ -55,7 +55,7 @@ void sendarp(int ifr_idx, const unsigned char* mac, in_addr_t ip)
memset(&sll, 0, sizeof(sll)); memset(&sll, 0, sizeof(sll));
sll.sll_family = AF_PACKET; sll.sll_family = AF_PACKET;
memcpy(sll.sll_addr, mac, sizeof(sll.sll_addr) - 1); memcpy(sll.sll_addr, mac, ETH_ALEN);
sll.sll_halen = ETH_ALEN; sll.sll_halen = ETH_ALEN;
sll.sll_ifindex = ifr_idx; sll.sll_ifindex = ifr_idx;