strace/0190-tests-sockopt-timestamp.c-use-k_getsockopt-and-k_set.patch

61 lines
1.9 KiB
Diff
Raw Permalink Normal View History

From cbda4efac4d55f8b3bf6622cdb764d2375a2cf3a Mon Sep 17 00:00:00 2001
From: Eugene Syromyatnikov <evgsyr@gmail.com>
Date: Thu, 31 Oct 2024 13:31:14 +0100
Subject: [PATCH 190/190] tests/sockopt-timestamp.c: use k_getsockopt and
k_setsockopt
Avoid using glibc wrappers as these performs additional actions
that lead to the following issues:
- Test segfault on 32-bit compat when an attempt to use
SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW with opt pointing to unavailable
memory is made;
- Additional calls to SO_TIMESTAMP{,NS}_OLD when SO_TIMESTAMP{NS}_NEW
are called:
-getsockopt(3, SOL_SOCKET, SO_TIMESTAMP_NEW, [0], [4]) = 0
[...]
+getsockopt(3, SOL_SOCKET, SO_TIMESTAMP_NEW, 0xf7d3cffc, [4]) = -1 ENOPROTOOPT (Protocol not available)
+getsockopt(3, SOL_SOCKET, SO_TIMESTAMP_OLD, [0], [4]) = 0
* tests/sockopt-sol_socket.c: Include "k_sockopt.h".
{get_sockopt): Use k_getsockopt() instead of getsockopt().
{set_sockopt): Use k_setsockopt() instead of setsockopt().
---
tests/sockopt-sol_socket.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tests/sockopt-sol_socket.c b/tests/sockopt-sol_socket.c
index 833aee6e1904..ee7a866c4385 100644
--- a/tests/sockopt-sol_socket.c
+++ b/tests/sockopt-sol_socket.c
@@ -13,6 +13,8 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include "k_sockopt.h"
+
#define XLAT_MACROS_ONLY
# include "xlat/sock_options.h"
#undef XLAT_MACROS_ONLY
@@ -34,7 +36,7 @@ struct intstr {
static int
get_sockopt(int fd, int name, void *val, socklen_t *len)
{
- rc = getsockopt(fd, SOL_SOCKET, name, val, len);
+ rc = k_getsockopt(fd, SOL_SOCKET, name, val, len);
errstr = sprintrc(rc);
return rc;
}
@@ -42,7 +44,7 @@ get_sockopt(int fd, int name, void *val, socklen_t *len)
static int
set_sockopt(int fd, int name, void *val, socklen_t len)
{
- rc = setsockopt(fd, SOL_SOCKET, name, val, len);
+ rc = k_setsockopt(fd, SOL_SOCKET, name, val, len);
errstr = sprintrc(rc);
return rc;
}
--
2.28.0