mirror of
https://github.com/curl/curl.git
synced 2026-08-26 21:24:08 +03:00
url: dns_entry related improvements
Replace Curl_resolv_unlock() with Curl_resolv_unlink(): -replace inuse member with refcount in Curl_dns_entry - pass Curl_dns_entry ** to unlink, so it gets always cleared - solve potential (but unlikley) UAF in FTP's handling of looked up Curl_dns_entry. Esp. do not use addr information after unlinking an entry. In reality, the unlink will not free memory, as the dns entry is still referenced by the hostcache. But this is not safe and relying on no other code pruning the cache in the meantime. - pass permanent flag when adding a dns entry instead of fixing timestamp afterwards. url.c: fold several static *resolve_* functions into one. Closes #14195
This commit is contained in:
parent
2372a5915c
commit
5a9262a333
14 changed files with 159 additions and 207 deletions
|
|
@ -679,12 +679,13 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
|
|||
conn->ip_version = ipver;
|
||||
|
||||
if(h) {
|
||||
int h_af = h->addr->ai_family;
|
||||
/* convert the resolved address, sizeof myhost >= INET_ADDRSTRLEN */
|
||||
Curl_printable_address(h->addr, myhost, sizeof(myhost));
|
||||
infof(data, "Name '%s' family %i resolved to '%s' family %i",
|
||||
host, af, myhost, h->addr->ai_family);
|
||||
Curl_resolv_unlock(data, h);
|
||||
if(af != h->addr->ai_family) {
|
||||
host, af, myhost, h_af);
|
||||
Curl_resolv_unlink(data, &h); /* this will NULL, potential free h */
|
||||
if(af != h_af) {
|
||||
/* bad IP version combo, signal the caller to try another address
|
||||
family if available */
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue