Skip to content

Commit

Permalink
fix(IPAddress) : Missing initialization and boggy comparison with IPv…
Browse files Browse the repository at this point in the history
…4 addresses
  • Loading branch information
mathieucarbou committed May 29, 2024
1 parent 79b8350 commit 763c4ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cores/esp32/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ IPAddress &IPAddress::operator=(const IPAddress &address) {
}

bool IPAddress::operator==(const IPAddress &addr) const {
return (addr._type == _type) && (memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0);
return (addr._type == _type) && (_type == IPType::IPv4 ? addr._address.dword[IPADDRESS_V4_DWORD_INDEX] == _address.dword[IPADDRESS_V4_DWORD_INDEX] : memcmp(addr._address.bytes, _address.bytes, sizeof(_address.bytes)) == 0);
}

bool IPAddress::operator==(const uint8_t *addr) const {
Expand Down Expand Up @@ -395,6 +395,9 @@ IPAddress &IPAddress::from_ip_addr_t(const ip_addr_t *addr) {
#endif /* LWIP_IPV6_SCOPES */
} else {
_type = IPv4;
_address.dword[0] = 0;
_address.dword[1] = 0;
_address.dword[2] = 0;
_address.dword[IPADDRESS_V4_DWORD_INDEX] = addr->u_addr.ip4.addr;
}
return *this;
Expand Down

0 comments on commit 763c4ad

Please sign in to comment.