Skip to content
Commit 1a359852 authored by Thomas Haller's avatar Thomas Haller Committed by Lennart Poettering
Browse files

in-addr-util: fix undefined result for in4_addr_netmask_to_prefixlen(<0.0.0.0>)

u32ctz() was undefined for zero due to __builtin_ctz() [1].
Explicitly check for zero to make the behavior defined.

Note that this issue only affected in4_addr_netmask_to_prefixlen()
which is the only caller.

It may seem slightly odd, to return 32 (bits) for utz(0). But that
is what in4_addr_netmask_to_prefixlen() needs, and it probably makes
the most sense here.

[1] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Fixes: ba914311
parent 0b109301
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment