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)
|
// copy over address (only IPv4 currently supported)
|
||||||
addr->m_len = sizeof(struct sockaddr_in);
|
if (info->h_addrtype == AF_INET) {
|
||||||
inaddr.sin_family = info->h_addrtype;
|
addr->m_len = sizeof(struct sockaddr_in);
|
||||||
inaddr.sin_port = 0;
|
inaddr.sin_family = info->h_addrtype;
|
||||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0], info->h_length);
|
inaddr.sin_port = 0;
|
||||||
memcpy(&addr->m_addr, &inaddr, addr->m_len);
|
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
|
// done with static buffer
|
||||||
ARCH->unlockMutex(m_mutex);
|
ARCH->unlockMutex(m_mutex);
|
||||||
|
|
|
@ -618,11 +618,14 @@ CArchNetworkWinsock::nameToAddr(const std::string& name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy over address (only IPv4 currently supported)
|
// copy over address (only IPv4 currently supported)
|
||||||
addr->m_len = sizeof(struct sockaddr_in);
|
if (info->h_addrtype == AF_INET) {
|
||||||
inaddr.sin_family = info->h_addrtype;
|
addr->m_len = sizeof(struct sockaddr_in);
|
||||||
inaddr.sin_port = 0;
|
inaddr.sin_family = info->h_addrtype;
|
||||||
memcpy(&inaddr.sin_addr, info->h_addr_list[0], info->h_length);
|
inaddr.sin_port = 0;
|
||||||
memcpy(&addr->m_addr, &inaddr, addr->m_len);
|
memcpy(&inaddr.sin_addr, info->h_addr_list[0],
|
||||||
|
sizeof(inaddr.sin_addr));
|
||||||
|
memcpy(&addr->m_addr, &inaddr, addr->m_len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
|
|
Loading…
Reference in New Issue