Compare commits
No commits in common. 'c8' and 'c9' have entirely different histories.
@ -0,0 +1,43 @@
|
|||||||
|
diff -Naur socat-1.7.3.3-orig/sysutils.c socat-1.7.3.3/sysutils.c
|
||||||
|
--- socat-1.7.3.3-orig/sysutils.c 2017-01-08 05:38:53.000000000 -0500
|
||||||
|
+++ socat-1.7.3.3/sysutils.c 2019-06-24 17:02:56.693056583 -0400
|
||||||
|
@@ -614,7 +614,7 @@
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
- strncpy(ifr.ifr_name, ifname, IFNAMSIZ); /* ok */
|
||||||
|
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); /* ok */
|
||||||
|
if (Ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
|
||||||
|
Info3("ioctl(%d, SIOCGIFINDEX, {\"%s\"}): %s",
|
||||||
|
s, ifr.ifr_name, strerror(errno));
|
||||||
|
diff -Naur socat-1.7.3.3-orig/xio-socket.c socat-1.7.3.3/xio-socket.c
|
||||||
|
--- socat-1.7.3.3-orig/xio-socket.c 2017-01-08 04:56:00.000000000 -0500
|
||||||
|
+++ socat-1.7.3.3/xio-socket.c 2019-06-24 17:04:48.684491835 -0400
|
||||||
|
@@ -1710,7 +1710,6 @@
|
||||||
|
int xiocheckpeer(xiosingle_t *xfd,
|
||||||
|
union sockaddr_union *pa, union sockaddr_union *la) {
|
||||||
|
char infobuff[256];
|
||||||
|
- int result;
|
||||||
|
|
||||||
|
#if WITH_IP4
|
||||||
|
if (xfd->para.socket.dorange) {
|
||||||
|
@@ -1778,6 +1777,7 @@
|
||||||
|
#endif /* WITH_TCP || WITH_UDP */
|
||||||
|
|
||||||
|
#if (WITH_TCP || WITH_UDP) && WITH_LIBWRAP
|
||||||
|
+ int result;
|
||||||
|
result = xio_tcpwrap_check(xfd, la, pa);
|
||||||
|
if (result < 0) {
|
||||||
|
char infobuff[256];
|
||||||
|
diff -Naur socat-1.7.3.3-orig/xio-tun.c socat-1.7.3.3/xio-tun.c
|
||||||
|
--- socat-1.7.3.3-orig/xio-tun.c 2017-01-06 15:58:40.000000000 -0500
|
||||||
|
+++ socat-1.7.3.3/xio-tun.c 2019-06-24 17:03:55.276797729 -0400
|
||||||
|
@@ -106,7 +106,7 @@
|
||||||
|
memset(&ifr, 0,sizeof(ifr));
|
||||||
|
|
||||||
|
if (retropt_string(opts, OPT_TUN_NAME, &tunname) == 0) {
|
||||||
|
- strncpy(ifr.ifr_name, tunname, IFNAMSIZ); /* ok */
|
||||||
|
+ strncpy(ifr.ifr_name, tunname, IFNAMSIZ - 1); /* ok */
|
||||||
|
free(tunname);
|
||||||
|
} else {
|
||||||
|
ifr.ifr_name[0] = '\0';
|
@ -0,0 +1,102 @@
|
|||||||
|
commit 1477334905be18c08bd6dc77be5a62e36b573de4
|
||||||
|
Author: Gerhard Rieger <gerhard@dest-unreach.org>
|
||||||
|
Date: Tue Oct 26 19:26:18 2021 +0200
|
||||||
|
|
||||||
|
OpenSSL server could be crashed by client cert with IPv6 address in SubjectAltname
|
||||||
|
|
||||||
|
diff --git a/test.sh b/test.sh
|
||||||
|
index 6ca21f3..c0e98a3 100755
|
||||||
|
--- a/test.sh
|
||||||
|
+++ b/test.sh
|
||||||
|
@@ -15040,6 +15040,60 @@ PORT=$((PORT+1))
|
||||||
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
|
+# Bug fix, OpenSSL server could be crashed by client cert with IPv6 address in SubjectAltname
|
||||||
|
+NAME=OPENSSL_CLIENT_IP6_CN
|
||||||
|
+case "$TESTS" in
|
||||||
|
+*%$N%*|*%functions%*|*%bugs%*|*%openssl%*|*%ip6%*|*%socket%*|*%$NAME%*)
|
||||||
|
+TEST="$NAME: Test if OpenSSL server may be crashed by client cert with IPv6 address"
|
||||||
|
+# Socat 1.7.4.1 had a bug that caused OpenSSL server to crash with SIGSEGV when
|
||||||
|
+# it checked a client certificate containing IPv6 address in SubjectAltName and
|
||||||
|
+# no openssl-commonname option was given
|
||||||
|
+if ! eval $NUMCOND; then :;
|
||||||
|
+elif ! testfeats openssl >/dev/null; then
|
||||||
|
+ $PRINTF "test $F_n $TEST... ${YELLOW}OPENSSL not available${NORMAL}\n" $N
|
||||||
|
+ numCANT=$((numCANT+1))
|
||||||
|
+ listCANT="$listCANT $N"
|
||||||
|
+elif ! testfeats tcp ip4 >/dev/null || ! runsip4 >/dev/null; then
|
||||||
|
+ $PRINTF "test $F_n $TEST... ${YELLOW}TCP/IPv4 not available${NORMAL}\n" $N
|
||||||
|
+ numCANT=$((numCANT+1))
|
||||||
|
+ listCANT="$listCANT $N"
|
||||||
|
+else
|
||||||
|
+gentestcert testsrv
|
||||||
|
+gentestaltcert testalt
|
||||||
|
+tf="$td/test$N.stdout"
|
||||||
|
+te="$td/test$N.stderr"
|
||||||
|
+tdiff="$td/test$N.diff"
|
||||||
|
+da="test$N $(date) $RANDOM"
|
||||||
|
+CMD0="$TRACE $SOCAT $opts -u OPENSSL-LISTEN:$PORT,reuseaddr,cert=./testsrv.pem,cafile=./testalt.crt -"
|
||||||
|
+CMD1="$TRACE $SOCAT $opts -u - OPENSSL-CONNECT:localhost:$PORT,cafile=testsrv.crt,cert=testalt.pem,verify=0"
|
||||||
|
+printf "test $F_n $TEST... " $N
|
||||||
|
+$CMD0 >/dev/null >"${tf}0" 2>"${te}0" &
|
||||||
|
+pid0=$!
|
||||||
|
+waittcp4port $PORT 1
|
||||||
|
+echo "$da" |$CMD1 2>"${te}1"
|
||||||
|
+rc1=$?
|
||||||
|
+kill $pid0 2>/dev/null; wait
|
||||||
|
+if [ $rc1 -eq 0 ] && echo "$da" |diff - "${tf}0" >$tdiff; then
|
||||||
|
+ $PRINTF "$OK\n"
|
||||||
|
+ 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
|
||||||
|
+
|
||||||
|
##################################################################################
|
||||||
|
#=================================================================================
|
||||||
|
# here come tests that might affect your systems integrity. Put normal tests
|
||||||
|
diff --git a/xio-openssl.c b/xio-openssl.c
|
||||||
|
index 94fe44e..dc47798 100644
|
||||||
|
--- a/xio-openssl.c
|
||||||
|
+++ b/xio-openssl.c
|
||||||
|
@@ -1775,15 +1775,17 @@ static int openssl_handle_peer_certificate(struct single *xfd,
|
||||||
|
#if WITH_IP6
|
||||||
|
case 16: /* IPv6 */
|
||||||
|
inet_ntop(AF_INET6, data, aBuffer, sizeof(aBuffer));
|
||||||
|
- xioip6_pton(peername, &ip6bin);
|
||||||
|
- if (memcmp(data, &ip6bin, sizeof(ip6bin)) == 0) {
|
||||||
|
- Debug2("subjectAltName \"%s\" matches peername \"%s\"",
|
||||||
|
- aBuffer, peername);
|
||||||
|
- ok = 1;
|
||||||
|
- } else {
|
||||||
|
- Info2("subjectAltName \"%s\" does not match peername \"%s\"",
|
||||||
|
- aBuffer, peername);
|
||||||
|
- }
|
||||||
|
+ if (peername != NULL) {
|
||||||
|
+ xioip6_pton(peername, &ip6bin);
|
||||||
|
+ if (memcmp(data, &ip6bin, sizeof(ip6bin)) == 0) {
|
||||||
|
+ Debug2("subjectAltName \"%s\" matches peername \"%s\"",
|
||||||
|
+ aBuffer, peername);
|
||||||
|
+ ok = 1;
|
||||||
|
+ } else {
|
||||||
|
+ Info2("subjectAltName \"%s\" does not match peername \"%s\"",
|
||||||
|
+ aBuffer, peername);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
Loading…
Reference in new issue