From: Valters Jansons Date: Wed, 26 Mar 2025 05:44:24 +0000 (+0000) Subject: address: Fix endianess problem when fetching octets in IPv4 addresses X-Git-Tag: debian/0.9.18-2~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afc69bc50d33154bc9df5b7d8b4e0af4791dbdbe;p=location%2Fdebian%2Flibloc.git address: Fix endianess problem when fetching octets in IPv4 addresses --- diff --git a/debian/patches/0001-address-Fix-endianess-problem.patch b/debian/patches/0001-address-Fix-endianess-problem.patch new file mode 100644 index 0000000..2cbb0dc --- /dev/null +++ b/debian/patches/0001-address-Fix-endianess-problem.patch @@ -0,0 +1,29 @@ +Subject: address: Fix endianess problem when fetching octets in IPv4 addresses +Origin: upstream, https://git.ipfire.org/?p=location/libloc.git;a=commit;h=afc5330f56d74b4a9142b800d994d623d7cd29e8 +Forwarded: not-needed +Author: Michael Tremer +Last-Update: 2025-03-10 +Applied-Upstream: commit:afc5330f56d74b4a9142b800d994d623d7cd29e8 + +The packaged 0.9.18 fails tests for s390x, as 10.0.0.0/32 becomes +an 10.0.0.0.in-addr.arpa., instead of expected 0.0.0.10.in-addr.arpa. + +--- + +diff --git a/src/libloc/address.h b/src/libloc/address.h +index ff6e943..e85d761 100644 +--- libloc-0.9.18.orig/src/libloc/address.h ++++ libloc-0.9.18/src/libloc/address.h +@@ -324,7 +324,11 @@ static inline int loc_address_get_octet(const struct in6_addr* address, const un + if (i >= 4) + return -ERANGE; + +- return (address->s6_addr32[3] >> (i * 8)) & 0xff; ++ // Format the IPv4 in host-byte order ++ unsigned int a4 = be32toh(address->s6_addr32[3]); ++ ++ // Return the nth byte from the left ++ return a4 >> ((3 - i) * 8) & 0xff; + + } else { + if (i >= 32) diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..218851b --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +0001-address-Fix-endianess-problem.patch