diff --git a/socat-configure-c99.patch b/socat-configure-c99.patch
new file mode 100644
index 0000000..37d8c4b
--- /dev/null
+++ b/socat-configure-c99.patch
@@ -0,0 +1,32 @@
+Include <openssl/err.h> for the ERR_error_string function.  This
+improves compatibility with future compilers which will not accept
+implicit funcction declarations by default.
+
+diff --git a/configure b/configure
+index fe4e606e91010520..694801b2a93659af 100755
+--- a/configure
++++ b/configure
+@@ -5199,6 +5199,8 @@ else
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ #include <openssl/ssl.h>
++      #include <openssl/err.h>
++
+ int
+ main ()
+ {
+diff --git a/configure.ac b/configure.ac
+index 09dbb7a1e8d35c84..abd599c90e3ef0d7 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -559,7 +559,9 @@ if test -n "$WITH_OPENSSL" -a "$sc_cv_have_openssl_ssl_h" = 'yes'; then
+       else
+ 	LIBS="$LIBS -lssl -lcrypto"
+       fi
+-      AC_TRY_LINK([#include <openssl/ssl.h>],
++      AC_TRY_LINK([#include <openssl/ssl.h>
++      #include <openssl/err.h>
++      ],
+        [SSL_library_init();ERR_error_string()],
+        [sc_cv_have_libssl='yes'],
+        [ LIBS="$LIBS -lcrypto"
diff --git a/socat.spec b/socat.spec
index f19ab7e..5e0aa49 100644
--- a/socat.spec
+++ b/socat.spec
@@ -3,12 +3,13 @@
 Summary: Bidirectional data relay between two data channels ('netcat++')
 Name: socat
 Version: 1.7.4.2
-Release: 3%{?dist}
+Release: 4%{?dist}
 License: GPLv2
 Url:  http://www.dest-unreach.org/socat/
 Source: http://www.dest-unreach.org/socat/download/%{name}-%{version}.tar.gz
 
 Patch1: socat-1.7.3.3-warn.patch
+Patch2: socat-configure-c99.patch
 
 BuildRequires: make
 BuildRequires:  gcc
@@ -30,6 +31,7 @@ line editor (readline), a program, or a combination of two of these.
 iconv -f iso8859-1 -t utf-8 CHANGES > CHANGES.utf8
 mv CHANGES.utf8 CHANGES
 %patch1 -p1
+%patch2 -p1
 
 %build
 %configure  \
@@ -73,6 +75,9 @@ export OD_C=/usr/bin/od
 %doc %{_mandir}/man1/*
 
 %changelog
+* Mon Dec 12 2022 Florian Weimer <fweimer@redhat.com> - 1.7.4.2-4
+- Port configure script to C99 (#2152488)
+
 * Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.4.2-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild