import CS socat-1.7.4.1-8.el9

This commit is contained in:
eabdullin 2025-09-15 12:48:46 +00:00
parent 6301bca3e0
commit 39a7e49c57
3 changed files with 138 additions and 3 deletions

View File

@ -0,0 +1,22 @@
http://www.dest-unreach.org/socat/contrib/socat-secadv9.html
--- socat-1.8.0.1/readline.sh 2019-04-04 10:59:55.000000000 +0200
+++ socat-1.8.0.2/readline.sh 2024-12-06 11:44:17.376502570 +0100
@@ -22,9 +22,15 @@
else
HISTOPT=
fi
-mkdir -p /tmp/$USER || exit 1
#
#
-exec socat -d readline"$HISTOPT",noecho='[Pp]assword:' exec:"$PROGRAM",sigint,pty,setsid,ctty,raw,echo=0,stderr 2>/tmp/$USER/stderr2
+if test -w .; then
+ STDERR=./socat-readline.${1##*/}.log
+ rm -f $STDERR
+else
+ STDERR=/dev/null
+fi
+
+exec socat -d readline"$HISTOPT",noecho='[Pp]assword:' exec:"$PROGRAM",sigint,pty,setsid,ctty,raw,echo=0,stderr 2>$STDERR

View File

@ -0,0 +1,101 @@
diff --git a/test.sh b/test.sh
index 99323ad..2869658 100755
--- a/test.sh
+++ b/test.sh
@@ -15017,6 +15017,60 @@ PORT=$((PORT+1))
N=$((N+1))
+
+# Test TCP with options connect-timeout and retry.
+# Up to 1.7.4.3 this terminated immediately on connection refused
+NAME=TCP_TIMEOUT_RETRY
+case "$TESTS" in
+*%$N%*|*%functions%*|*%bugs%*|*%tcp%*|*%socket%*|*%$NAME%*)
+TEST="$NAME: TCP with options connect-timeout and retry"
+# In background run a delayed echo server
+# In foreground start TCP with connect-timeout and retry. On first attempt the
+# server is not listening; when socat makes a second attempt that succeeds, the
+# bug is absent and the test succeeded.
+if ! eval $NUMCOND; then :; else
+tf="$td/test$N.stdout"
+te="$td/test$N.stderr"
+tdiff="$td/test$N.diff"
+da="test$N $(date) $RANDOM"
+CMD0="sleep 1 && $TRACE $SOCAT $opts TCP-L:$PORT,reuseaddr PIPE"
+CMD1="$TRACE $SOCAT $opts - TCP:$LOCALHOST:$PORT,connect-timeout=2,retry=1,interval=2"
+printf "test $F_n $TEST... " $N
+eval "$CMD0" >/dev/null 2>"${te}0" &
+pid0=$!
+echo "$da" |$CMD1 >"${tf}1" 2>"${te}1"
+rc1=$?
+kill $pid0 2>/dev/null; wait
+if [ $rc1 -ne 0 ]; then
+ $PRINTF "$FAILED\n"
+ echo "$CMD0 &" >&2
+ cat "${te}0" >&2
+ echo "$CMD1" >&2
+ cat "${te}1" >&2
+ numFAIL=$((numFAIL+1))
+ listFAIL="$listFAIL $N"
+elif echo "$da" |diff - "${tf}1" >$tdiff; then
+ $PRINTF "$OK\n"
+ if [ "$VERBOSE" ]; then
+ echo "$CMD0 &" >&2
+ echo "$CMD1" >&2
+ fi
+ numOK=$((numOK+1))
+else
+ $PRINTF "$FAILED\n"
+ echo "$CMD0 &" >&2
+ cat "${te}0" >&2
+ echo "$CMD1" >&2
+ cat "${te}1" >&2
+ numFAIL=$((numFAIL+1))
+ listFAIL="$listFAIL $N"
+fi
+fi # NUMCOND
+ ;;
+esac
+PORT=$((PORT+1))
+N=$((N+1))
+
# end of common tests
##################################################################################
diff --git a/xio-socket.c b/xio-socket.c
index c1495e8..d6b935c 100644
--- a/xio-socket.c
+++ b/xio-socket.c
@@ -859,6 +859,8 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
xfd->para.socket.connect_timeout.tv_usec != 0) {
struct timeval timeout;
struct pollfd writefd;
+ int err;
+ socklen_t errlen = sizeof(err);
int result;
Info4("connect(%d, %s, "F_Zd"): %s",
@@ -894,7 +896,21 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
#endif
return STAT_RETRYLATER;
}
- /* otherwise OK */
+ /* otherwise OK or network error */
+ result = Getsockopt(xfd->fd, SOL_SOCKET, SO_ERROR, &err, &errlen);
+ if (result != 0) {
+ Msg2(level, "getsockopt(%d, SOL_SOCKET, SO_ERROR, ...): %s",
+ xfd->fd, strerror(err));
+ return STAT_RETRYLATER;
+ }
+ Debug2("getsockopt(%d, SOL_SOCKET, SO_ERROR, { %d }) -> 0",
+ xfd->fd, err);
+ if (err != 0) {
+ Msg4(level, "connect(%d, %s, "F_Zd"): %s",
+ xfd->fd, sockaddr_info(them, themlen, infobuff, sizeof(infobuff)),
+ themlen, strerror(err));
+ return STAT_RETRYLATER;
+ }
Fcntl_l(xfd->fd, F_SETFL, fcntl_flags);
} else {
Warn4("connect(%d, %s, "F_Zd"): %s",

View File

@ -3,7 +3,7 @@
Summary: Bidirectional data relay between two data channels ('netcat++')
Name: socat
Version: 1.7.4.1
Release: 6%{?dist}
Release: 8%{?dist}
License: GPLv2
Url: http://www.dest-unreach.org/socat/
Source: http://www.dest-unreach.org/socat/download/%{name}-%{version}.tar.gz
@ -12,6 +12,10 @@ Patch1: socat-1.7.3.3-warn.patch
# https://issues.redhat.com/browse/RHEL-32438
# Based on: https://repo.or.cz/socat.git/commit/1477334905be18c08bd6dc77be5a62e36b573de4
Patch2: socat-1.7.4.1-ipv6-peername-segfault.patch
Patch3: socat-1.7.4.1-CVE-2024-54661.patch
# https://issues.redhat.com/browse/RHEL-107884
# Based on: https://repo.or.cz/socat.git/commit/ed4780553fd05bb8ed8a29462698090482be3393
Patch4: socat-1.7.4.1-tcp-address-with-connect-timeout.patch
BuildRequires: make
BuildRequires: gcc
@ -32,8 +36,7 @@ line editor (readline), a program, or a combination of two of these.
%setup -q
iconv -f iso8859-1 -t utf-8 CHANGES > CHANGES.utf8
mv CHANGES.utf8 CHANGES
%patch1 -p1
%patch2 -p1
%autopatch -p1
%build
%configure \
@ -77,6 +80,15 @@ export OD_C=/usr/bin/od
%doc %{_mandir}/man1/*
%changelog
* Thu Aug 07 2025 Martin Osvald <mosvald@redhat.com> - 1.7.4.1-8
- Fix for: Client may exit 0 despite connection being reset
Resolves: RHEL-107884
* Wed Jun 04 2025 Martin Osvald <mosvald@redhat.com> - 1.7.4.1-7
- add fix for CVE-2024-54661
Resolves: RHEL-94843
- switch to autopatch, remove unused patches
* Mon Apr 15 2024 Martin Osvald <mosvald@redhat.com> - 1.7.4.1-6
- Fix IPv6 peername segfault (RHEL-32438)