-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
From 35badf22978cf2ead330d9cce3c2ddb825184b48 Mon Sep 17 00:00:00 2001 | ||
From: jykanase <v-jykanase@microsoft.com> | ||
Date: Wed, 22 Jan 2025 10:42:04 +0000 | ||
Subject: [PATCH] CVE-2024-9681.patch | ||
|
||
Backported form: https://github.com/curl/curl/commit/a94973805df96269bf3f3bf0a20ccb9887313316 | ||
--- | ||
Utilities/cmcurl/lib/hsts.c | 14 ++++++++++---- | ||
1 file changed, 10 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/Utilities/cmcurl/lib/hsts.c b/Utilities/cmcurl/lib/hsts.c | ||
index 97a07ec4..bd2b3ce7 100644 | ||
--- a/Utilities/cmcurl/lib/hsts.c | ||
+++ b/Utilities/cmcurl/lib/hsts.c | ||
@@ -232,11 +232,13 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname, | ||
struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, | ||
bool subdomain) | ||
{ | ||
+ struct stsentry *bestsub = NULL; | ||
if(h) { | ||
time_t now = time(NULL); | ||
size_t hlen = strlen(hostname); | ||
struct Curl_llist_element *e; | ||
struct Curl_llist_element *n; | ||
+ size_t blen = 0; | ||
for(e = h->list.head; e; e = n) { | ||
struct stsentry *sts = e->ptr; | ||
n = e->next; | ||
@@ -251,15 +253,19 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, | ||
if(ntail < hlen) { | ||
size_t offs = hlen - ntail; | ||
if((hostname[offs-1] == '.') && | ||
- Curl_strncasecompare(&hostname[offs], sts->host, ntail)) | ||
- return sts; | ||
+ Curl_strncasecompare(&hostname[offs], sts->host, ntail) && | ||
+ (ntail > blen)) { | ||
+ /* save the tail match with the longest tail */ | ||
+ bestsub = sts; | ||
+ blen = ntail; | ||
+ } | ||
} | ||
} | ||
if(Curl_strcasecompare(hostname, sts->host)) | ||
return sts; | ||
} | ||
} | ||
- return NULL; /* no match */ | ||
+ return bestsub; | ||
} | ||
|
||
/* | ||
@@ -412,7 +418,7 @@ static CURLcode hsts_add(struct hsts *h, char *line) | ||
e = Curl_hsts(h, p, subdomain); | ||
if(!e) | ||
result = hsts_create(h, p, subdomain, expires); | ||
- else { | ||
+ else if(strcasecompare(p, e->host)) { | ||
/* the same host name, use the largest expire time */ | ||
if(expires > e->expires) | ||
e->expires = expires; | ||
-- | ||
2.45.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters