mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-13 18:50:54 -04:00
4524. [bug] The net zero test was broken causing IPv4 servers
with addresses ending in .0 to be rejected. [RT #43776]
(cherry picked from commit df372d967e)
This commit is contained in:
parent
52254f7526
commit
5be93f5dff
4 changed files with 75 additions and 6 deletions
3
CHANGES
3
CHANGES
|
|
@ -1,3 +1,6 @@
|
|||
4524. [bug] The net zero test was broken causing IPv4 servers
|
||||
with addresses ending in .0 to be rejected. [RT #43776]
|
||||
|
||||
4523. [doc] Expand config doc for <querysource4> and
|
||||
<querysource6>. [RT #43768]
|
||||
|
||||
|
|
|
|||
|
|
@ -409,15 +409,15 @@ isc_netaddr_issitelocal(isc_netaddr_t *na) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef IN_ZERONET
|
||||
#define IN_ZERONET(x) (((x) & htonl(0xff000000U)) == 0)
|
||||
#endif
|
||||
#define ISC_IPADDR_ISNETZERO(i) \
|
||||
(((isc_uint32_t)(i) & ISC__IPADDR(0xff000000)) \
|
||||
== ISC__IPADDR(0x00000000))
|
||||
|
||||
isc_boolean_t
|
||||
isc_netaddr_isnetzero(isc_netaddr_t *na) {
|
||||
switch (na->family) {
|
||||
case AF_INET:
|
||||
return (ISC_TF(IN_ZERONET(na->type.in.s_addr)));
|
||||
return (ISC_TF(ISC_IPADDR_ISNETZERO(na->type.in.s_addr)));
|
||||
case AF_INET6:
|
||||
return (ISC_FALSE);
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ SRCS = isctest.c taskpool_test.c socket_test.c hash_test.c \
|
|||
parse_test.c pool_test.c print_test.c regex_test.c \
|
||||
socket_test.c safe_test.c time_test.c aes_test.c \
|
||||
file_test.c buffer_test.c counter_test.c mem_test.c \
|
||||
result_test.c ht_test.c errno_test.c
|
||||
result_test.c ht_test.c errno_test.c netaddr_test.c
|
||||
|
||||
SUBDIRS =
|
||||
TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
||||
|
|
@ -42,7 +42,7 @@ TARGETS = taskpool_test@EXEEXT@ socket_test@EXEEXT@ hash_test@EXEEXT@ \
|
|||
safe_test@EXEEXT@ time_test@EXEEXT@ aes_test@EXEEXT@ \
|
||||
file_test@EXEEXT@ buffer_test@EXEEXT@ counter_test@EXEEXT@ \
|
||||
mem_test@EXEEXT@ result_test@EXEEXT@ ht_test@EXEEXT@ \
|
||||
errno_test@EXEEXT@
|
||||
errno_test@EXEEXT@ netaddr_test@EXEEXT@
|
||||
|
||||
@BIND9_MAKE_RULES@
|
||||
|
||||
|
|
@ -143,6 +143,10 @@ errno_test@EXEEXT@: errno_test.@O@ ${ISCDEPLIBS}
|
|||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
errno_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
netaddr_test@EXEEXT@: netaddr_test.@O@ ${ISCDEPLIBS}
|
||||
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
|
||||
netaddr_test.@O@ ${ISCLIBS} ${LIBS}
|
||||
|
||||
unit::
|
||||
sh ${top_srcdir}/unit/unittest.sh
|
||||
|
||||
|
|
|
|||
62
lib/isc/tests/netaddr_test.c
Normal file
62
lib/isc/tests/netaddr_test.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
/* ! \file */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/netaddr.h>
|
||||
|
||||
ATF_TC(isc_netaddr_isnetzero);
|
||||
ATF_TC_HEAD(isc_netaddr_isnetzero, tc) {
|
||||
atf_tc_set_md_var(tc, "descr", "test isc_netaddr_isnetzero");
|
||||
}
|
||||
ATF_TC_BODY(isc_netaddr_isnetzero, tc) {
|
||||
unsigned int i;
|
||||
struct in_addr ina;
|
||||
struct {
|
||||
const char *address;
|
||||
isc_boolean_t expect;
|
||||
} tests[] = {
|
||||
{ "0.0.0.0", ISC_TRUE },
|
||||
{ "0.0.0.1", ISC_TRUE },
|
||||
{ "0.0.1.2", ISC_TRUE },
|
||||
{ "0.1.2.3", ISC_TRUE },
|
||||
{ "10.0.0.0", ISC_FALSE },
|
||||
{ "10.9.0.0", ISC_FALSE },
|
||||
{ "10.9.8.0", ISC_FALSE },
|
||||
{ "10.9.8.7", ISC_FALSE },
|
||||
{ "127.0.0.0", ISC_FALSE },
|
||||
{ "127.0.0.1", ISC_FALSE }
|
||||
};
|
||||
isc_boolean_t result;
|
||||
isc_netaddr_t netaddr;
|
||||
|
||||
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
|
||||
ina.s_addr = inet_addr(tests[i].address);
|
||||
isc_netaddr_fromin(&netaddr, &ina);
|
||||
result = isc_netaddr_isnetzero(&netaddr);
|
||||
ATF_CHECK_EQ_MSG(result, tests[i].expect,
|
||||
"%s", tests[i].address);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
ATF_TP_ADD_TCS(tp) {
|
||||
|
||||
ATF_TP_ADD_TC(tp, isc_netaddr_isnetzero);
|
||||
|
||||
return (atf_no_error());
|
||||
}
|
||||
Loading…
Reference in a new issue