chiark / gitweb /
network-address,test-network: avoid undefined behaviour
[elogind.git] / src / network / networkd-address.c
index ce0e923..47033ac 100644 (file)
@@ -592,6 +592,10 @@ bool address_equal(Address *a1, Address *a2) {
         case AF_INET:
                 if (a1->prefixlen != a2->prefixlen)
                         return false;
         case AF_INET:
                 if (a1->prefixlen != a2->prefixlen)
                         return false;
+                else if (a1->prefixlen == 0)
+                        /* make sure we don't try to shift by 32.
+                         * See ISO/IEC 9899:TC3 ยง 6.5.7.3. */
+                        return true;
                 else {
                         uint32_t b1, b2;
 
                 else {
                         uint32_t b1, b2;