mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Fix memory corruption with DNS lookups.
Thanks @Mystler for finding and reporting this, and thanks @Hoikas for investigating and confirming the fix.
This commit is contained in:
@ -88,9 +88,6 @@ static unsigned s_nextLookupCancelId = 1;
|
|||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
static void LookupProcess (Lookup * lookup, unsigned error) {
|
static void LookupProcess (Lookup * lookup, unsigned error) {
|
||||||
unsigned count = 0;
|
|
||||||
plNetAddress* addrs = nil;
|
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -104,20 +101,14 @@ static void LookupProcess (Lookup * lookup, unsigned error) {
|
|||||||
|
|
||||||
in_addr const * const * const inAddr = (in_addr **) host.h_addr_list;
|
in_addr const * const * const inAddr = (in_addr **) host.h_addr_list;
|
||||||
|
|
||||||
// count the number of addresses
|
|
||||||
while (inAddr[count])
|
|
||||||
++count;
|
|
||||||
|
|
||||||
// allocate a buffer large enough to hold all the addresses
|
// allocate a buffer large enough to hold all the addresses
|
||||||
addrs = new plNetAddress[count];
|
size_t count = arrsize(inAddr);
|
||||||
|
plNetAddress* addrs = new plNetAddress[count];
|
||||||
|
|
||||||
// fill in address data
|
// fill in address data
|
||||||
const uint16_t port = htons((uint16_t) lookup->port);
|
for (size_t i = 0; i < count; ++i) {
|
||||||
for (unsigned i = 0; i < count; ++i) {
|
addrs[i].SetHost(inAddr[i]->S_un.S_addr);
|
||||||
sockaddr_in * inetaddr = (sockaddr_in *) &addrs[i];
|
addrs[i].SetPort(lookup->port);
|
||||||
inetaddr->sin_family = AF_INET;
|
|
||||||
inetaddr->sin_addr = *inAddr[i];
|
|
||||||
inetaddr->sin_port = port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host.h_name && host.h_name[0])
|
if (host.h_name && host.h_name[0])
|
||||||
|
Reference in New Issue
Block a user