summaryrefslogtreecommitdiffstats
path: root/lib/hsts.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hsts.c')
-rw-r--r--lib/hsts.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/hsts.c b/lib/hsts.c
index 607755e..a5e7676 100644
--- a/lib/hsts.c
+++ b/lib/hsts.c
@@ -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);