|
| 1 | +From 35badf22978cf2ead330d9cce3c2ddb825184b48 Mon Sep 17 00:00:00 2001 |
| 2 | +From: jykanase <v-jykanase@microsoft.com> |
| 3 | +Date: Wed, 22 Jan 2025 10:42:04 +0000 |
| 4 | +Subject: [PATCH] CVE-2024-9681.patch |
| 5 | + |
| 6 | +Backported form: https://github.com/curl/curl/commit/a94973805df96269bf3f3bf0a20ccb9887313316 |
| 7 | +--- |
| 8 | + Utilities/cmcurl/lib/hsts.c | 14 ++++++++++---- |
| 9 | + 1 file changed, 10 insertions(+), 4 deletions(-) |
| 10 | + |
| 11 | +diff --git a/Utilities/cmcurl/lib/hsts.c b/Utilities/cmcurl/lib/hsts.c |
| 12 | +index 97a07ec4..bd2b3ce7 100644 |
| 13 | +--- a/Utilities/cmcurl/lib/hsts.c |
| 14 | ++++ b/Utilities/cmcurl/lib/hsts.c |
| 15 | +@@ -232,11 +232,13 @@ CURLcode Curl_hsts_parse(struct hsts *h, const char *hostname, |
| 16 | + struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, |
| 17 | + bool subdomain) |
| 18 | + { |
| 19 | ++ struct stsentry *bestsub = NULL; |
| 20 | + if(h) { |
| 21 | + time_t now = time(NULL); |
| 22 | + size_t hlen = strlen(hostname); |
| 23 | + struct Curl_llist_element *e; |
| 24 | + struct Curl_llist_element *n; |
| 25 | ++ size_t blen = 0; |
| 26 | + for(e = h->list.head; e; e = n) { |
| 27 | + struct stsentry *sts = e->ptr; |
| 28 | + n = e->next; |
| 29 | +@@ -251,15 +253,19 @@ struct stsentry *Curl_hsts(struct hsts *h, const char *hostname, |
| 30 | + if(ntail < hlen) { |
| 31 | + size_t offs = hlen - ntail; |
| 32 | + if((hostname[offs-1] == '.') && |
| 33 | +- Curl_strncasecompare(&hostname[offs], sts->host, ntail)) |
| 34 | +- return sts; |
| 35 | ++ Curl_strncasecompare(&hostname[offs], sts->host, ntail) && |
| 36 | ++ (ntail > blen)) { |
| 37 | ++ /* save the tail match with the longest tail */ |
| 38 | ++ bestsub = sts; |
| 39 | ++ blen = ntail; |
| 40 | ++ } |
| 41 | + } |
| 42 | + } |
| 43 | + if(Curl_strcasecompare(hostname, sts->host)) |
| 44 | + return sts; |
| 45 | + } |
| 46 | + } |
| 47 | +- return NULL; /* no match */ |
| 48 | ++ return bestsub; |
| 49 | + } |
| 50 | + |
| 51 | + /* |
| 52 | +@@ -412,7 +418,7 @@ static CURLcode hsts_add(struct hsts *h, char *line) |
| 53 | + e = Curl_hsts(h, p, subdomain); |
| 54 | + if(!e) |
| 55 | + result = hsts_create(h, p, subdomain, expires); |
| 56 | +- else { |
| 57 | ++ else if(strcasecompare(p, e->host)) { |
| 58 | + /* the same host name, use the largest expire time */ |
| 59 | + if(expires > e->expires) |
| 60 | + e->expires = expires; |
| 61 | +-- |
| 62 | +2.45.2 |
| 63 | + |
0 commit comments