return h;
}
-static void hsts_free(struct stsentry *e)
-{
- curlx_free(CURL_UNCONST(e->host));
- curlx_free(e);
-}
+#define hsts_free(x) curlx_free(x)
void Curl_hsts_cleanup(struct hsts **hp)
{
/* strip off any trailing dot */
--hlen;
if(hlen) {
- char *duphost;
- struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry));
+ struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry) + hlen);
if(!sts)
return CURLE_OUT_OF_MEMORY;
-
- duphost = Curl_memdup0(hostname, hlen);
- if(!duphost) {
- curlx_free(sts);
- return CURLE_OUT_OF_MEMORY;
- }
-
- sts->host = duphost;
+ /* the null terminator is already there */
+ memcpy(sts->host, hostname, hlen);
sts->expires = expires;
sts->includeSubDomains = subdomains;
Curl_llist_append(&h->list, sts, &sts->node);
struct tm stamp;
CURLcode result;
- e.name = (char *)CURL_UNCONST(sts->host);
+ e.name = (char *)sts->host;
e.namelen = strlen(sts->host);
e.includeSubDomains = sts->includeSubDomains;
struct stsentry {
struct Curl_llist_node node;
- const char *host;
curl_off_t expires; /* the timestamp of this entry's expiry */
BIT(includeSubDomains);
+ char host[1];
};
/* The HSTS cache. Needs to be able to tailmatch hostnames. */