]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: fix the ::1 comparison for IPv6 localhost for cookies
authorDaniel Stenberg <daniel@haxx.se>
Tue, 20 Dec 2022 09:07:36 +0000 (10:07 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 20 Dec 2022 12:50:15 +0000 (13:50 +0100)
When checking if there is a "secure context", which it is if the
connection is to localhost even if the protocol is HTTP, the comparison
for ::1 was done incorrectly and included brackets.

Reported-by: BratSinot on github
Fixes #10120
Closes #10121

lib/http.c

index a784745a8d505208c5463bd65527ae5094c41965..1b7502280ebb797847590f4fed1cd1b4d6550c36 100644 (file)
@@ -2714,7 +2714,7 @@ CURLcode Curl_http_cookies(struct Curl_easy *data,
         conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) ||
         strcasecompare("localhost", host) ||
         !strcmp(host, "127.0.0.1") ||
-        !strcmp(host, "[::1]") ? TRUE : FALSE;
+        !strcmp(host, "::1") ? TRUE : FALSE;
       Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE);
       co = Curl_cookie_getlist(data, data->cookies, host, data->state.up.path,
                                secure_context);
@@ -3553,7 +3553,7 @@ CURLcode Curl_http_header(struct Curl_easy *data, struct connectdata *conn,
       conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) ||
       strcasecompare("localhost", host) ||
       !strcmp(host, "127.0.0.1") ||
-      !strcmp(host, "[::1]") ? TRUE : FALSE;
+      !strcmp(host, "::1") ? TRUE : FALSE;
 
     Curl_share_lock(data, CURL_LOCK_DATA_COOKIE,
                     CURL_LOCK_ACCESS_SINGLE);