trafgen: Check pointer in ipv6 device address lookup function
commitb23c1519f14a2c93f7927996844522e3caede79c
authorMatPerin <matteoperin1302@gmail.com>
Fri, 15 Apr 2022 02:15:07 +0000 (14 22:15 -0400)
committerTobias Klauser <tobias.klauser@gmail.com>
Fri, 22 Apr 2022 09:20:09 +0000 (22 11:20 +0200)
tree438a08989277c943cc3abba6223f4afc116cae14
parentf0187ac5c6b9ee8d600521a88e4c8a482744171c
trafgen: Check pointer in ipv6 device address lookup function

The getifaddrs function returns a linked list node for L2
even in the case of L3 interfaces (e.g. a TUN device), but
with the pointer to the address structure set to NULL.
This causes a segfault when trying to access the address
family from it when such network interfaces are present
in the system.

The issue is solved by checking the validity of the pointer
beforehand: if the address structure is present the address
family can be fetched and the current iteration can go on
safely, otherwise the node is skipped (as it is not linked
to any address).

Signed-off-by: Matteo Perin <matteoperin1302@gmail.com>
dev.c