mirror of
https://github.com/curl/curl.git
synced 2026-04-14 23:51:42 +03:00
hostip: don't store negative resolves due unrelated errors
Like for: - OOM - resolver_start() returns error - DoH has problems Fixes #18953 Fixes #18954 Reported-by: Joshua Rogers Closes #18958
This commit is contained in:
parent
7ab9018ea7
commit
b0db5f12b1
1 changed files with 12 additions and 6 deletions
18
lib/hostip.c
18
lib/hostip.c
|
|
@ -846,6 +846,7 @@ CURLcode Curl_resolv(struct Curl_easy *data,
|
|||
int respwait = 0;
|
||||
bool is_ipaddr;
|
||||
size_t hostname_len;
|
||||
bool keep_negative = TRUE; /* cache a negative result */
|
||||
|
||||
#ifndef CURL_DISABLE_DOH
|
||||
data->conn->bits.doh = FALSE; /* default is not */
|
||||
|
|
@ -887,8 +888,10 @@ CURLcode Curl_resolv(struct Curl_easy *data,
|
|||
st = data->set.resolver_start(resolver, NULL,
|
||||
data->set.resolver_start_client);
|
||||
Curl_set_in_callback(data, FALSE);
|
||||
if(st)
|
||||
if(st) {
|
||||
keep_negative = FALSE;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* shortcut literal IP addresses, if we are not told to resolve them. */
|
||||
|
|
@ -947,10 +950,11 @@ out:
|
|||
else if(addr) {
|
||||
/* we got a response, create a dns entry, add to cache, return */
|
||||
dns = Curl_dnscache_mk_entry(data, addr, hostname, 0, port, FALSE);
|
||||
if(!dns)
|
||||
goto error;
|
||||
if(Curl_dnscache_add(data, dns))
|
||||
if(!dns || Curl_dnscache_add(data, dns)) {
|
||||
/* this is OOM or similar, don't store such negative resolves */
|
||||
keep_negative = FALSE;
|
||||
goto error;
|
||||
}
|
||||
show_resolve_info(data, dns);
|
||||
*entry = dns;
|
||||
return CURLE_OK;
|
||||
|
|
@ -966,7 +970,8 @@ error:
|
|||
Curl_resolv_unlink(data, &dns);
|
||||
*entry = NULL;
|
||||
Curl_async_shutdown(data);
|
||||
store_negative_resolve(data, hostname, port);
|
||||
if(keep_negative)
|
||||
store_negative_resolve(data, hostname, port);
|
||||
return CURLE_COULDNT_RESOLVE_HOST;
|
||||
}
|
||||
|
||||
|
|
@ -1550,7 +1555,8 @@ CURLcode Curl_resolv_check(struct Curl_easy *data,
|
|||
result = Curl_async_is_resolved(data, dns);
|
||||
if(*dns)
|
||||
show_resolve_info(data, *dns);
|
||||
if(result)
|
||||
if((result == CURLE_COULDNT_RESOLVE_HOST) ||
|
||||
(result == CURLE_COULDNT_RESOLVE_PROXY))
|
||||
store_negative_resolve(data, data->state.async.hostname,
|
||||
data->state.async.port);
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue