Fix endian bug in --local-service code.

This commit is contained in:
Richard Genoud
2014-09-17 21:12:00 +01:00
committed by Simon Kelley
parent 00c0f69aa5
commit 15b1b7e9c3
2 changed files with 5 additions and 2 deletions

View File

@@ -49,6 +49,9 @@ version 2.71
regression introduced in 2.69. Thanks to James Hunt and regression introduced in 2.69. Thanks to James Hunt and
the Ubuntu crowd for assistance in fixing this. the Ubuntu crowd for assistance in fixing this.
Fix problem with --local-service option on big-endian platforms
Thanks to Richard Genoud for the patch.
version 2.70 version 2.70
Fix crash, introduced in 2.69, on TCP request when dnsmasq Fix crash, introduced in 2.69, on TCP request when dnsmasq

View File

@@ -1118,7 +1118,7 @@ void receive_query(struct listener *listen, time_t now)
struct in_addr netmask; struct in_addr netmask;
for (addr = daemon->interface_addrs; addr; addr = addr->next) for (addr = daemon->interface_addrs; addr; addr = addr->next)
{ {
netmask.s_addr = 0xffffffff << (32 - addr->prefixlen); netmask.s_addr = htonl(~(in_addr_t)0 << (32 - addr->prefixlen));
if (!(addr->flags & ADDRLIST_IPV6) && if (!(addr->flags & ADDRLIST_IPV6) &&
is_same_net(addr->addr.addr.addr4, source_addr.in.sin_addr, netmask)) is_same_net(addr->addr.addr.addr4, source_addr.in.sin_addr, netmask))
break; break;
@@ -1652,7 +1652,7 @@ unsigned char *tcp_request(int confd, time_t now,
struct in_addr netmask; struct in_addr netmask;
for (addr = daemon->interface_addrs; addr; addr = addr->next) for (addr = daemon->interface_addrs; addr; addr = addr->next)
{ {
netmask.s_addr = 0xffffffff << (32 - addr->prefixlen); netmask.s_addr = htonl(~(in_addr_t)0 << (32 - addr->prefixlen));
if (!(addr->flags & ADDRLIST_IPV6) && if (!(addr->flags & ADDRLIST_IPV6) &&
is_same_net(addr->addr.addr.addr4, peer_addr.in.sin_addr, netmask)) is_same_net(addr->addr.addr.addr4, peer_addr.in.sin_addr, netmask))
break; break;