File iputils-invalid-ttl-s390x.patch of Package iputils.38674
From c9c82b4576f0b616793ffbdc815c02e2e4da1f5c Mon Sep 17 00:00:00 2001
From: Radoslav Kolev <radoslav.kolev@suse.com>
Date: Thu, 15 May 2025 17:56:52 +0300
Subject: [PATCH] ping: Fix ipv4 ttl value when using SOCK_DGRAM on big endian
systems
7e7ffff attempted to fix a GCC warning about strict aliasing (which
it seems may have been an erroneous one in the first place), but
caused the ttl value when pinging an ipv4 address using SOCK_DGRAM
on a big endian system (for ex. IBM S390) to always appear as 0.
Using memcpy() instead of directly casting the value should be the
safest option, fixing the issue and also avoiding the possibility
of unaligned access to the value returned by CMSG_DATA.
Fixes: 7e7ffff ("ping: Silence GCC warnings when building with -fstrict-aliasing")
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Radoslav Kolev <radoslav.kolev@suse.com>
---
ping/ping.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Index: iputils-s20161105/ping.c
===================================================================
--- iputils-s20161105.orig/ping.c
+++ iputils-s20161105/ping.c
@@ -1050,7 +1050,7 @@ ping4_parse_reply(struct socket_st *sock
int csfailed;
struct cmsghdr *cmsg;
int ttl;
- __u8 *opts, *tmp_ttl;
+ __u8 *opts;
int optlen;
/* Check the IP header */
@@ -1077,8 +1077,7 @@ ping4_parse_reply(struct socket_st *sock
if (cmsg->cmsg_type == IP_TTL) {
if (cmsg->cmsg_len < sizeof(int))
continue;
- tmp_ttl = (__u8 *) CMSG_DATA(cmsg);
- ttl = (int)*tmp_ttl;
+ memcpy(&ttl, CMSG_DATA(cmsg), sizeof(ttl));
} else if (cmsg->cmsg_type == IP_RETOPTS) {
opts = (__u8 *) CMSG_DATA(cmsg);
optlen = cmsg->cmsg_len;