From: Petr Písař Date: Wed, 12 Mar 2025 10:08:00 +0000 (+0100) Subject: Fix endianess when fetching octets from an IPv4 address X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=56ef7bc9b49b7d0bc7335bd4a4f3922943999584;p=location%2Ffedora%2Flibloc.git Fix endianess when fetching octets from an IPv4 address --- diff --git a/libloc-0.9.18-address-Fix-endianess-problem-when-fetching-octets-i.patch b/libloc-0.9.18-address-Fix-endianess-problem-when-fetching-octets-i.patch new file mode 100644 index 0000000..a2c866a --- /dev/null +++ b/libloc-0.9.18-address-Fix-endianess-problem-when-fetching-octets-i.patch @@ -0,0 +1,36 @@ +From afc5330f56d74b4a9142b800d994d623d7cd29e8 Mon Sep 17 00:00:00 2001 +From: Michael Tremer +Date: Mon, 10 Mar 2025 15:13:07 +0000 +Subject: [PATCH] address: Fix endianess problem when fetching octets in IPv4 + addresses +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fixes: #13828 +Signed-off-by: Michael Tremer +Signed-off-by: Petr Písař +--- + src/libloc/address.h | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/libloc/address.h b/src/libloc/address.h +index ff6e943..e85d761 100644 +--- a/src/libloc/address.h ++++ b/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) +-- +2.48.1 + diff --git a/libloc.spec b/libloc.spec index 9196b5a..a997edb 100644 --- a/libloc.spec +++ b/libloc.spec @@ -94,6 +94,9 @@ License: LGPL-2.1-or-later SourceLicense: LGPL-2.1-or-later AND CC-BY-SA-4.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl) AND GPL-2.0-or-later AND GPL-2.0-or-later WITH Autoconf-exception-macro AND FSFAP AND FSFULLR URL: https://location.ipfire.org/ Source0: https://source.ipfire.org/releases/%{name}/%{name}-%{version}.tar.gz +# Fix endianess when fetching octets from an IPv4 address, +# upstream bug #13828, in upstream after 0.9.18 +Patch0: libloc-0.9.18-address-Fix-endianess-problem-when-fetching-octets-i.patch BuildRequires: asciidoc BuildRequires: autoconf >= 2.60 # autoconf-archive for unbundled m4/ax_prog_perl_modules.m4