hostip: enforce a maximum DNS cache size independent of timeout value

To reduce the damage an application can cause if using -1 or other
ridiculous timeout values and letting the cache live long times.

The maximum number of entries in the DNS cache is now totally
arbitrarily and hard-coded set to 29999.

Closes #11084
This commit is contained in:
Daniel Stenberg 2023-05-08 11:11:36 +02:00
parent f62557276a
commit 9ed7d56e04
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 42 additions and 13 deletions

View file

@ -37,15 +37,23 @@ memory and used for this number of seconds. Set to zero to completely disable
caching, or set to -1 to make the cached entries remain forever. By default,
libcurl caches this info for 60 seconds.
We recommend users not to tamper with this option unless strictly necessary.
If you do, be careful of using large values that can make the cache size grow
significantly if many different host names are used within that timeout
period.
The name resolve functions of various libc implementations do not re-read name
server information unless explicitly told so (for example, by calling
\fIres_init(3)\fP). This may cause libcurl to keep using the older server even
if DHCP has updated the server info, and this may look like a DNS cache issue
to the casual libcurl-app user.
Note that DNS entries have a "TTL" property but libcurl does not use that. This
DNS cache timeout is entirely speculative that a name will resolve to the same
DNS entries have a "TTL" property but libcurl does not use that. This DNS
cache timeout is entirely speculative that a name will resolve to the same
address for a certain small amount of time into the future.
Since version 8.1.0, libcurl prunes entries from the DNS cache if it excceeds
30,000 entries no matter which timeout value is used.
.SH DEFAULT
60
.SH PROTOCOLS