mirror of
https://github.com/curl/curl.git
synced 2026-07-25 04:57:15 +03:00
doh: cap the maximum TTL to 24 hours
To avoid mistakes or abuse to cause problems. Many public DNS providers cap their cache times to this. Verify in test 1650 Reported-by: netspacer.research Closes #22122
This commit is contained in:
parent
8ed285f06d
commit
e8e3af2abb
2 changed files with 14 additions and 9 deletions
|
|
@ -725,7 +725,9 @@ UNITTEST void de_init(struct dohentry *de)
|
|||
curlx_dyn_init(&de->cname[i], DYN_DOH_CNAME);
|
||||
}
|
||||
|
||||
/* @unittest 1655 */
|
||||
/* TTL value cap */
|
||||
#define MAX_DNS_TTL 86400U /* 24 hours */
|
||||
/* @unittest 1650 */
|
||||
UNITTEST DOHcode doh_resp_decode(const unsigned char *doh,
|
||||
size_t dohlen,
|
||||
DNStype dnstype,
|
||||
|
|
@ -795,6 +797,8 @@ UNITTEST DOHcode doh_resp_decode(const unsigned char *doh,
|
|||
return DOH_DNS_OUT_OF_RANGE;
|
||||
|
||||
ttl = doh_get32bit(doh, index);
|
||||
if(ttl > MAX_DNS_TTL)
|
||||
ttl = MAX_DNS_TTL;
|
||||
if(ttl < d->ttl)
|
||||
d->ttl = ttl;
|
||||
index += 4;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue