Hello community,

here is the log from the commit of package target-isns for openSUSE:Factory 
checked in at 2015-10-25 19:13:08
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/target-isns (Old)
 and      /work/SRC/openSUSE:Factory/.target-isns.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "target-isns"

Changes:
--------
--- /work/SRC/openSUSE:Factory/target-isns/target-isns.changes  2015-08-12 
15:14:08.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.target-isns.new/target-isns.changes     
2015-10-25 19:13:09.000000000 +0100
@@ -1,0 +2,9 @@
+Wed Oct 21 17:23:05 UTC 2015 - [email protected]
+
+- Handle 2 places isnsd was handling IP addresses
+  incorrectly, assuming big-endian architecture (bsc#950366),
+  adding two patches:
+  * target-isns-handle-big-endian-arch.patch
+  * target-isns-fix-remaining-little-endian-IP-addr.patch
+
+-------------------------------------------------------------------

New:
----
  target-isns-fix-remaining-little-endian-IP-addr.patch
  target-isns-handle-big-endian-arch.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ target-isns.spec ++++++
--- /var/tmp/diff_new_pack.nSL4OW/_old  2015-10-25 19:13:10.000000000 +0100
+++ /var/tmp/diff_new_pack.nSL4OW/_new  2015-10-25 19:13:10.000000000 +0100
@@ -37,6 +37,8 @@
 Patch2:         %{name}-add-systemd-support.patch
 Patch3:         %{name}-dont-ignore-read-return-value.patch
 Patch4:         %{name}-define-posix_c_source-for-netdb
+Patch5:         %{name}-fix-remaining-little-endian-IP-addr.patch
+Patch6:         %{name}-handle-big-endian-arch.patch
 
 %description
 Target-isns is an Internet Storage Name Service (iSNS) client for the
@@ -56,6 +58,8 @@
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
+%patch5 -p1
+%patch6 -p1
 
 %build
 mkdir build

++++++ target-isns-fix-remaining-little-endian-IP-addr.patch ++++++
>From a7222ebb245ca79c74f83cb881eeb8ae73a7f39f Mon Sep 17 00:00:00 2001
From: Lee Duncan <[email protected]>
Date: Thu, 15 Oct 2015 18:21:17 -0700
Subject: [PATCH] Fix remaining little-endian IP address handling

My prevoius fix missed one place where the IP
address was still reversed on big-endian architectures.
---
 src/isns.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/src/isns.c
+++ b/src/isns.c
@@ -454,10 +454,7 @@ static void isns_ip_addr_set(const struc
 
                /* RFC 4171 6.3.1: convert v4 to mapped v6 */
                ip_addr[10] = ip_addr[11] = 0xff;
-               ip_addr[15] = 0xff & (addr >> 24);
-               ip_addr[14] = 0xff & (addr >> 16);
-               ip_addr[13] = 0xff & (addr >> 8);
-               ip_addr[12] = 0xff & addr;
+               memcpy(ip_addr + 12, &addr, 4);
        } else if (portal->af == AF_INET6)
                inet_pton(AF_INET6, portal->ip_addr, ip_addr);
 }
++++++ target-isns-handle-big-endian-arch.patch ++++++
From: Olaf Kirch <[email protected]>
Date: Wed Oct 14 10:51:18 PDT 2015
Subject: [PATCH] Handle big-endian architecture
Reference: bsc#950366

On a little Endian system, this will load addr with the IP address in
"wrong" order, ie if the address was 1.2.3.4, then addr will contain
04030201

                ip[10] = ip[11] = 0xff;
                ip[15] = 0xff & (addr >> 24);
                ip[14] = 0xff & (addr >> 16);
                ip[13] = 0xff & (addr >> 8);
                ip[12] = 0xff & addr;

Using the example IP addr above, his will translate to

                /* addr == 0x04030201 */
                ip[15] = 4; /* 0xff & (addr >> 24); */
                ip[14] = 3; /* 0xff & (addr >> 16); */
                ip[13] = 2; /* 0xff & (addr >> 8); */
                ip[12] = 1; /* 0xff & addr; */

On a big Endian system, the contents of addr will not be byte swapped,
and hence it will be stored in ip[] in the wrong order.

This picture doesn't change when using ntohl, because that is a NOP on
s390. The only effect of using ntohl is that it will now be broken on
x86_64 as well :-)

The real fix is to not bother with assigning to addr at all, but to do
a memcpy straight from &l.s4)->sin_addr to ip + 12. That doesn't need
any byte aerobics, as it just moves the data as-is.

Signed-of-by: Lee Duncan <[email protected]>
---
 src/isns.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

--- a/src/isns.c
+++ b/src/isns.c
@@ -77,7 +77,6 @@ static int isns_get_ip(int fd)
 {
        int err;
        size_t i;
-       uint32_t addr;
        union {
                struct sockaddr s;
                struct sockaddr_storage ss;
@@ -104,13 +103,8 @@ static int isns_get_ip(int fd)
 
        switch (l.ss.ss_family) {
        case AF_INET:
-               addr = ((&l.s4)->sin_addr.s_addr);
-
                ip[10] = ip[11] = 0xff;
-               ip[15] = 0xff & (addr >> 24);
-               ip[14] = 0xff & (addr >> 16);
-               ip[13] = 0xff & (addr >> 8);
-               ip[12] = 0xff & addr;
+               memcpy(ip + 12, &((&l.s4)->sin_addr), 4);
                break;
        case AF_INET6:
                for (i = 0; i < ARRAY_SIZE(ip); i++)

Reply via email to