mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
src: add self-assigment memcpy checks
Fixes: https://github.com/nodejs/node/issues/56718 PR-URL: https://github.com/nodejs/node/pull/56986 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
@@ -79,12 +79,16 @@ SocketAddress::SocketAddress(const SocketAddress& addr) {
|
||||
}
|
||||
|
||||
SocketAddress& SocketAddress::operator=(const sockaddr* addr) {
|
||||
memcpy(&address_, addr, GetLength(addr));
|
||||
if (reinterpret_cast<const sockaddr*>(&address_) != addr) {
|
||||
memcpy(&address_, addr, GetLength(addr));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
SocketAddress& SocketAddress::operator=(const SocketAddress& addr) {
|
||||
memcpy(&address_, &addr.address_, addr.length());
|
||||
if (this != &addr) {
|
||||
memcpy(&address_, &addr.address_, addr.length());
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user