ec60169
From 187d0795030ccb4f410eb6089e265ac3571e56dd Mon Sep 17 00:00:00 2001
ec60169
From: Daniel Stenberg <daniel@haxx.se>
ec60169
Date: Mon, 25 Apr 2022 11:48:00 +0200
ec60169
Subject: [PATCH] conncache: include the zone id in the "bundle" hashkey
ec60169
ec60169
Make connections to two separate IPv6 zone ids create separate
ec60169
connections.
ec60169
ec60169
Reported-by: Harry Sintonen
ec60169
Bug: https://curl.se/docs/CVE-2022-27775.html
ec60169
Closes #8747
ec60169
ec60169
Upstream-commit: 058f98dc3fe595f21dc26a5b9b1699e519ba5705
ec60169
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
ec60169
---
ec60169
 lib/conncache.c | 8 ++++++--
ec60169
 1 file changed, 6 insertions(+), 2 deletions(-)
ec60169
ec60169
diff --git a/lib/conncache.c b/lib/conncache.c
ec60169
index cd5756a..9b9f683 100644
ec60169
--- a/lib/conncache.c
ec60169
+++ b/lib/conncache.c
ec60169
@@ -160,8 +160,12 @@ static void hashkey(struct connectdata *conn, char *buf,
ec60169
     /* report back which name we used */
ec60169
     *hostp = hostname;
ec60169
 
ec60169
-  /* put the number first so that the hostname gets cut off if too long */
ec60169
-  msnprintf(buf, len, "%ld%s", port, hostname);
ec60169
+  /* put the numbers first so that the hostname gets cut off if too long */
ec60169
+#ifdef ENABLE_IPV6
ec60169
+  msnprintf(buf, len, "%u/%ld/%s", conn->scope_id, port, hostname);
ec60169
+#else
ec60169
+  msnprintf(buf, len, "%ld/%s", port, hostname);
ec60169
+#endif
ec60169
   Curl_strntolower(buf, buf, len);
ec60169
 }
ec60169
 
ec60169
-- 
ec60169
2.34.1
ec60169