a3dace
From e786483fb4b6fd2460c9a58ad7074e82ecf91747 Mon Sep 17 00:00:00 2001
a3dace
From: Tomas Hoger <thoger@redhat.com>
a3dace
Date: Thu, 19 Aug 2021 16:50:02 +0200
a3dace
Subject: [PATCH] Upstream patch for CVE-2021-38165
a3dace
a3dace
Extracted from lynx 2.9.0dev.9.
a3dace
a3dace
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1994998#c2
a3dace
---
a3dace
 WWW/Library/Implementation/HTTP.c | 18 ++++++++++++++++++
a3dace
 1 file changed, 18 insertions(+)
a3dace
a3dace
diff --git a/WWW/Library/Implementation/HTTP.c b/WWW/Library/Implementation/HTTP.c
a3dace
index 41ab849..4a50b41 100644
a3dace
--- a/WWW/Library/Implementation/HTTP.c
a3dace
+++ b/WWW/Library/Implementation/HTTP.c
a3dace
@@ -762,6 +762,23 @@ static char *StripIpv6Brackets(char *host)
a3dace
 }
a3dace
 #endif
a3dace
 
a3dace
+/*
a3dace
+ * Remove user/password, if any, from the given host-string.
a3dace
+ */
a3dace
+#ifdef USE_SSL
a3dace
+static char *StripUserAuthents(char *host)
a3dace
+{
a3dace
+    char *p = strchr(host, '@');
a3dace
+
a3dace
+    if (p != NULL) {
a3dace
+	char *q = host;
a3dace
+
a3dace
+	while ((*q++ = *++p) != '\0') ;
a3dace
+    }
a3dace
+    return host;
a3dace
+}
a3dace
+#endif
a3dace
+
a3dace
 /*		Load Document from HTTP Server			HTLoadHTTP()
a3dace
  *		==============================
a3dace
  *
a3dace
@@ -957,6 +974,7 @@ static int HTLoadHTTP(const char *arg,
a3dace
 	/* get host we're connecting to */
a3dace
 	ssl_host = HTParse(url, "", PARSE_HOST);
a3dace
 	ssl_host = StripIpv6Brackets(ssl_host);
a3dace
+	ssl_host = StripUserAuthents(ssl_host);
a3dace
 #if defined(USE_GNUTLS_FUNCS)
a3dace
 	ret = gnutls_server_name_set(handle->gnutls_state,
a3dace
 				     GNUTLS_NAME_DNS,
a3dace
-- 
a3dace
2.31.1
a3dace