Changed name-to-address translation to only use IPv4 addresses
and to only copy as much address as fits in sockaddr_in.sin_addr, in case hostent.h_length is wrong.
This commit is contained in:
parent
33e359a384
commit
80f3998398
|
@ -611,11 +611,14 @@ CArchNetworkBSD::nameToAddr(const std::string& name)
|
|||
}
|
||||
|
||||
// copy over address (only IPv4 currently supported)
|
||||
if (info->h_addrtype == AF_INET) {
|
||||
addr->m_len = sizeof(struct sockaddr_in);
|
||||
inaddr.sin_family = info->h_addrtype;
|
||||
inaddr.sin_port = 0;
|
||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0], info->h_length);
|
||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0],
|
||||
sizeof(inaddr.sin_addr));
|
||||
memcpy(&addr->m_addr, &inaddr, addr->m_len);
|
||||
}
|
||||
|
||||
// done with static buffer
|
||||
ARCH->unlockMutex(m_mutex);
|
||||
|
|
|
@ -618,12 +618,15 @@ CArchNetworkWinsock::nameToAddr(const std::string& name)
|
|||
}
|
||||
|
||||
// copy over address (only IPv4 currently supported)
|
||||
if (info->h_addrtype == AF_INET) {
|
||||
addr->m_len = sizeof(struct sockaddr_in);
|
||||
inaddr.sin_family = info->h_addrtype;
|
||||
inaddr.sin_port = 0;
|
||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0], info->h_length);
|
||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0],
|
||||
sizeof(inaddr.sin_addr));
|
||||
memcpy(&addr->m_addr, &inaddr, addr->m_len);
|
||||
}
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue