]> git.ipfire.org Git - people/ms/network.git/commitdiff
netcalc: Fix comparing IP addresses
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Sep 2016 16:39:15 +0000 (18:39 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Sep 2016 16:39:15 +0000 (18:39 +0200)
Those are stored in big endian

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/inetcalc.c

index 8af506252bb6f104de85e9e6b94705e2d265fd49..ad256c505e42af1ae95ed3e7257365cc6d16da44 100644 (file)
@@ -193,8 +193,10 @@ static int ip_address_gt(const ip_address_t* a1, const ip_address_t* a2) {
        if (a1->family != a2->family || a1->prefix != a2->prefix)
                return -1;
 
-       if (a1->addr.s6_addr > a2->addr.s6_addr)
-               return 0;
+       for (unsigned int i = 0; i < 4; i++) {
+               if (a1->addr.s6_addr[i] > a2->addr.s6_addr[i])
+                       return 0;
+       }
 
        return 1;
 }