arp(8): avoid segfaulting due to out-of-bounds memory access

Fix obvious mistake that sometimes results in reading memory
past end of an array.

PR:		240825
MFC after:	1 week
This commit is contained in:
eugen 2020-01-09 11:58:26 +00:00
parent f2c97d8528
commit a136cbafca

View File

@ -627,8 +627,7 @@ print_entry(struct sockaddr_dl *sdl,
} else
xo_emit("{d:/(incomplete)}{en:incomplete/true}");
for (p = ifnameindex; p && ifnameindex->if_index &&
ifnameindex->if_name; p++) {
for (p = ifnameindex; p && p->if_index && p->if_name; p++) {
if (p->if_index == sdl->sdl_index) {
xo_emit(" on {:interface/%s}", p->if_name);
break;