summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/hsts.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-31 15:02:45 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-31 15:02:45 (GMT)
commite28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4 (patch)
tree61d94e6d1e595c9ab06bac9e70a153162f523ab8 /Utilities/cmcurl/lib/hsts.c
parent692463d271c5afae5c48b8f05117a9a2e035d6be (diff)
parent851cc904a0f3615c9560a2eeba83e04556c0090b (diff)
downloadCMake-e28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4.zip
CMake-e28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4.tar.gz
CMake-e28ea90c1be2e7d3963effa3f7d80f2c8bf3d1d4.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2024-01-31 (5ce164e0)
Diffstat (limited to 'Utilities/cmcurl/lib/hsts.c')
-rw-r--r--Utilities/cmcurl/lib/hsts.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/Utilities/cmcurl/lib/hsts.c b/Utilities/cmcurl/lib/hsts.c
index 9314be2..8725a35 100644
--- a/Utilities/cmcurl/lib/hsts.c
+++ b/Utilities/cmcurl/lib/hsts.c
@@ -117,8 +117,6 @@ static CURLcode hsts_create(struct hsts *h,
bool subdomains,
curl_off_t expires)
{
- struct stsentry *sts;
- char *duphost;
size_t hlen;
DEBUGASSERT(h);
DEBUGASSERT(hostname);
@@ -127,24 +125,23 @@ static CURLcode hsts_create(struct hsts *h,
if(hlen && (hostname[hlen - 1] == '.'))
/* strip off any trailing dot */
--hlen;
- if(!hlen)
- /* no host name left */
- return CURLE_BAD_FUNCTION_ARGUMENT;
-
- sts = hsts_entry();
- if(!sts)
- return CURLE_OUT_OF_MEMORY;
+ if(hlen) {
+ char *duphost;
+ struct stsentry *sts = hsts_entry();
+ if(!sts)
+ return CURLE_OUT_OF_MEMORY;
+
+ duphost = Curl_memdup0(hostname, hlen);
+ if(!duphost) {
+ free(sts);
+ return CURLE_OUT_OF_MEMORY;
+ }
- duphost = Curl_strndup(hostname, hlen);
- if(!duphost) {
- free(sts);
- return CURLE_OUT_OF_MEMORY;
+ sts->host = duphost;
+ sts->expires = expires;
+ sts->includeSubDomains = subdomains;
+ Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);
}
-
- sts->host = duphost;
- sts->expires = expires;
- sts->includeSubDomains = subdomains;
- Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);
return CURLE_OK;
}
@@ -481,6 +478,7 @@ static CURLcode hsts_pull(struct Curl_easy *data, struct hsts *h)
if(sc == CURLSTS_OK) {
time_t expires;
CURLcode result;
+ DEBUGASSERT(e.name[0]);
if(!e.name[0])
/* bail out if no name was stored */
return CURLE_BAD_FUNCTION_ARGUMENT;