diff options
author | Curl Upstream <curl-library@lists.haxx.se> | 2024-05-22 05:54:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-05-29 17:59:48 (GMT) |
commit | 9f46cdb65da8f66c9894ff55ab59ebe8a4058538 (patch) | |
tree | 6f346296943bf34983abe2ff91206d581ed850d0 /lib/hsts.c | |
parent | e17d8d0c3b8f820bd108b8d66ace3692c81bbf42 (diff) | |
download | CMake-9f46cdb65da8f66c9894ff55ab59ebe8a4058538.zip CMake-9f46cdb65da8f66c9894ff55ab59ebe8a4058538.tar.gz CMake-9f46cdb65da8f66c9894ff55ab59ebe8a4058538.tar.bz2 |
curl 2024-05-22 (fd567d4f)
Code extracted from:
https://github.com/curl/curl.git
at commit fd567d4f06857f4fc8e2f64ea727b1318f76ad33 (curl-8_8_0).
Diffstat (limited to 'lib/hsts.c')
-rw-r--r-- | lib/hsts.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -107,11 +107,6 @@ void Curl_hsts_cleanup(struct hsts **hp) } } -static struct stsentry *hsts_entry(void) -{ - return calloc(1, sizeof(struct stsentry)); -} - static CURLcode hsts_create(struct hsts *h, const char *hostname, bool subdomains, @@ -127,7 +122,7 @@ static CURLcode hsts_create(struct hsts *h, --hlen; if(hlen) { char *duphost; - struct stsentry *sts = hsts_entry(); + struct stsentry *sts = calloc(1, sizeof(struct stsentry)); if(!sts) return CURLE_OUT_OF_MEMORY; @@ -140,7 +135,7 @@ static CURLcode hsts_create(struct hsts *h, sts->host = duphost; sts->expires = expires; sts->includeSubDomains = subdomains; - Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node); + Curl_llist_append(&h->list, sts, &sts->node); } return CURLE_OK; } @@ -528,8 +523,11 @@ static CURLcode hsts_load(struct hsts *h, const char *file) char *lineptr = Curl_dyn_ptr(&buf); while(*lineptr && ISBLANK(*lineptr)) lineptr++; - if(*lineptr == '#') - /* skip commented lines */ + /* + * Skip empty or commented lines, since we know the line will have a + * trailing newline from Curl_get_line we can treat length 1 as empty. + */ + if((*lineptr == '#') || strlen(lineptr) <= 1) continue; hsts_add(h, lineptr); |