Skip to content

Commit 0f1162e

Browse files
committed
ipv4: Fix ip4_addr_netmask_valid()
Use right API to convert from network to host byte order. Address 0 is not a valid netmask.
1 parent be81388 commit 0f1162e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/ipv4/ip4_addr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ u8_t
9393
ip4_addr_netmask_valid(u32_t netmask)
9494
{
9595
u32_t mask;
96-
u32_t nm_hostorder = lwip_htonl(netmask);
96+
u32_t nm_hostorder = lwip_ntohl(netmask);
97+
98+
if (nm_hostorder == 0) {
99+
return 0;
100+
}
97101

98102
/* first, check for the first zero */
99103
for (mask = 1UL << 31 ; mask != 0; mask >>= 1) {

0 commit comments

Comments
 (0)