mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
CaresPTRResolver small safety improvement
Previous to #40769, only `hostent::h_aliases` was being accessed. After that PR got merged, `hostent::h_name` started being accessed as well. This PR moves the first `hostent::h_aliases != nullptr` check that could prevent `hostent::h_name` from being accessed. During debugging, I observed that even when there are not aliases, `hostent::h_aliases` is not null. That's why it hasn't caused any problems, but proposing this change to be on the safe side.
This commit is contained in:
parent
29ac78a92b
commit
fb42afbbac
@ -15,8 +15,8 @@ namespace DB
|
|||||||
|
|
||||||
static void callback(void * arg, int status, int, struct hostent * host)
|
static void callback(void * arg, int status, int, struct hostent * host)
|
||||||
{
|
{
|
||||||
auto * ptr_records = reinterpret_cast<std::unordered_set<std::string>*>(arg);
|
auto * ptr_records = static_cast<std::unordered_set<std::string>*>(arg);
|
||||||
if (status == ARES_SUCCESS && host->h_aliases)
|
if (ptr_records && status == ARES_SUCCESS)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* In some cases (e.g /etc/hosts), hostent::h_name is filled and hostent::h_aliases is empty.
|
* In some cases (e.g /etc/hosts), hostent::h_name is filled and hostent::h_aliases is empty.
|
||||||
@ -28,6 +28,8 @@ namespace DB
|
|||||||
ptr_records->insert(ptr_record);
|
ptr_records->insert(ptr_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (host->h_aliases)
|
||||||
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (auto * ptr_record = host->h_aliases[i])
|
while (auto * ptr_record = host->h_aliases[i])
|
||||||
{
|
{
|
||||||
@ -36,6 +38,7 @@ namespace DB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CaresPTRResolver::CaresPTRResolver(CaresPTRResolver::provider_token) : channel(nullptr)
|
CaresPTRResolver::CaresPTRResolver(CaresPTRResolver::provider_token) : channel(nullptr)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user