]> git.ipfire.org Git - thirdparty/util-linux.git/commit
netaddrq: Fix crash if there are no IP addresses
authorStanislav Brabec <sbrabec@suse.cz>
Tue, 7 Oct 2025 23:14:32 +0000 (01:14 +0200)
committerStanislav Brabec <sbrabec@suse.cz>
Tue, 7 Oct 2025 23:19:29 +0000 (01:19 +0200)
commit60c5c0516e6ce52863b12343a1cd276423ab3bae
treedc6785b2419a238cda41c3fc7c2cc2dcb46eba9b
parent83a9a2226b1d1f59b1555100b6c4f2f8b3e7e4cf
netaddrq: Fix crash if there are no IP addresses

If there are no IP addresses, ul_netaddrq_bestaddr() returns threshold
ULNETLINK_RATING_BAD, but there were no addresses in the best array, and
best_ifaceq remains unset, which caused crash. Setting the initial
threshold to __ULNETLINK_RATING_MAX and checking for that value fixes that.
And more, it also allows to accept IP addresses with ULNETLINK_RATING_BAD
rating.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
include/netaddrq.h
lib/netaddrq.c
term-utils/agetty.c