]> git.ipfire.org Git - location/libloc.git/commitdiff
address: Correctly subtract IPv4 addresses
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Mar 2022 11:27:31 +0000 (11:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 7 Mar 2022 11:27:31 +0000 (11:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libloc/private.h

index d6bebdf9e59ad69fe1f351cd72c0e06fc129ea87..41a89299f480214057a7a670ee6dcd26517ffcf4 100644 (file)
@@ -212,7 +212,7 @@ static inline int __loc_address4_sub(struct in6_addr* result,
                const struct in6_addr* address1, const struct in6_addr* address2) {
        int remainder = 0;
 
-       for (int octet = 4; octet >= 0; octet--) {
+       for (int octet = 15; octet >= 12; octet--) {
                int x = address1->s6_addr[octet] - address2->s6_addr[octet] + remainder;
 
                // Store remainder for the next iteration