mirror of
https://github.com/curl/curl.git
synced 2026-08-25 02:23:31 +03:00
parent
65597f8fc9
commit
9ec63d8565
2 changed files with 6 additions and 17 deletions
21
lib/hsts.c
21
lib/hsts.c
|
|
@ -75,11 +75,7 @@ struct hsts *Curl_hsts_init(void)
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsts_free(struct stsentry *e)
|
#define hsts_free(x) curlx_free(x)
|
||||||
{
|
|
||||||
curlx_free(CURL_UNCONST(e->host));
|
|
||||||
curlx_free(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Curl_hsts_cleanup(struct hsts **hp)
|
void Curl_hsts_cleanup(struct hsts **hp)
|
||||||
{
|
{
|
||||||
|
|
@ -111,18 +107,11 @@ static CURLcode hsts_create(struct hsts *h,
|
||||||
/* strip off any trailing dot */
|
/* strip off any trailing dot */
|
||||||
--hlen;
|
--hlen;
|
||||||
if(hlen) {
|
if(hlen) {
|
||||||
char *duphost;
|
struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry) + hlen);
|
||||||
struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry));
|
|
||||||
if(!sts)
|
if(!sts)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
|
/* the null terminator is already there */
|
||||||
duphost = Curl_memdup0(hostname, hlen);
|
memcpy(sts->host, hostname, hlen);
|
||||||
if(!duphost) {
|
|
||||||
curlx_free(sts);
|
|
||||||
return CURLE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
sts->host = duphost;
|
|
||||||
sts->expires = expires;
|
sts->expires = expires;
|
||||||
sts->includeSubDomains = subdomains;
|
sts->includeSubDomains = subdomains;
|
||||||
Curl_llist_append(&h->list, sts, &sts->node);
|
Curl_llist_append(&h->list, sts, &sts->node);
|
||||||
|
|
@ -294,7 +283,7 @@ static CURLcode hsts_push(struct Curl_easy *data,
|
||||||
struct tm stamp;
|
struct tm stamp;
|
||||||
CURLcode result;
|
CURLcode result;
|
||||||
|
|
||||||
e.name = (char *)CURL_UNCONST(sts->host);
|
e.name = (char *)sts->host;
|
||||||
e.namelen = strlen(sts->host);
|
e.namelen = strlen(sts->host);
|
||||||
e.includeSubDomains = sts->includeSubDomains;
|
e.includeSubDomains = sts->includeSubDomains;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ extern time_t deltatime;
|
||||||
|
|
||||||
struct stsentry {
|
struct stsentry {
|
||||||
struct Curl_llist_node node;
|
struct Curl_llist_node node;
|
||||||
const char *host;
|
|
||||||
curl_off_t expires; /* the timestamp of this entry's expiry */
|
curl_off_t expires; /* the timestamp of this entry's expiry */
|
||||||
BIT(includeSubDomains);
|
BIT(includeSubDomains);
|
||||||
|
char host[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The HSTS cache. Needs to be able to tailmatch hostnames. */
|
/* The HSTS cache. Needs to be able to tailmatch hostnames. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue