Unverified Commit 98ce7204 authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #429 from knowledge4igor/fix_memory_defects_in_net

Fix memory defects in net
parents f95ee72f 0019d545
......@@ -238,8 +238,8 @@ Address::init(const std::string& addr) {
family_ = AF_INET6;
try {
in6_addr addr6;
char buff6[INET6_ADDRSTRLEN+1];
memcpy(buff6, host_.c_str(), INET6_ADDRSTRLEN);
char buff6[INET6_ADDRSTRLEN + 1] = {0, };
std::copy(host_.begin(), host_.end(), buff6);
inet_pton(AF_INET6, buff6, &(addr6.s6_addr16));
} catch (std::runtime_error) {
throw std::invalid_argument("Invalid IPv6 address");
......@@ -257,8 +257,8 @@ Address::init(const std::string& addr) {
}
try {
in_addr addr;
char buff[INET_ADDRSTRLEN+1];
memcpy(buff, host_.c_str(), INET_ADDRSTRLEN);
char buff[INET_ADDRSTRLEN + 1] = {0, };
std::copy(host_.begin(), host_.end(), buff);
inet_pton(AF_INET, buff, &(addr));
} catch (std::runtime_error) {
throw std::invalid_argument("Invalid IPv4 address");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment