Files
Open_Ultra_SAST/benchmarks/pairs/vfc/curl-cve-2022-30115/fixed.c
T

42 lines
1.1 KiB
C
Raw Normal View History

/* Provenance: curl/curl hsts_create (fixed).
* repo: curl/curl
* commit: fae6fea209a2d4db1582f608bd8cc8000721733a
* parent: ff3ee510c328db03bf171cae6179bb9463fb054f
* commit_url: https://github.com/curl/curl/commit/fae6fea209a2d4db1582f608bd8cc8000721733a
* cve: CVE-2022-30115
* license: curl
* function: hsts_create
* relpath: lib/hsts.c
* provenance: human
* mechanism: other
*/
static CURLcode hsts_create(struct hsts *h,
const char *hostname,
bool subdomains,
curl_off_t expires)
{
struct stsentry *sts = hsts_entry();
char *duphost;
size_t hlen;
if(!sts)
return CURLE_OUT_OF_MEMORY;
duphost = strdup(hostname);
if(!duphost) {
free(sts);
return CURLE_OUT_OF_MEMORY;
}
hlen = strlen(duphost);
if(duphost[hlen - 1] == '.')
/* strip off trailing any dot */
duphost[--hlen] = 0;
sts->host = duphost;
sts->expires = expires;
sts->includeSubDomains = subdomains;
Curl_llist_insert_next(&h->list, h->list.tail, sts, &sts->node);
return CURLE_OK;
}