Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36f93f01 authored by Stan Chesnutt's avatar Stan Chesnutt
Browse files

fix undefined behavior with certain left-shift count values

Change-Id: I1b71de28312a56a3b1d27fcfaf0a7b71d5777e6c
parent e88a1b9e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -224,6 +224,11 @@ in_addr_t get_ipv4_netmask(int prefix_length)
{
    in_addr_t mask = 0;

    // C99 (6.5.7): shifts of 32 bits have undefined results
    if (prefix_length == 0) {
        return 0;
    }

    mask = ~mask << (32 - prefix_length);
    mask = htonl(mask);