4430. [bug] Lwresd died if a search list was not defined.
Found by 0x710DDDD At Alibaba Security. [RT #42895]
(cherry picked from commit 3146be6fd6)
This commit is contained in:
@@ -23,4 +23,5 @@ rm -f */named.memstats
|
||||
rm -f */named.run
|
||||
rm -f dig.out
|
||||
rm -f lwresd1/lwresd.run.resolv
|
||||
rm -f lwresd1/lwresd.run.lwresd
|
||||
rm -f lwresd*/lwresd.run
|
||||
|
||||
24
bin/tests/system/lwresd/lwresd1/nosearch.conf
Normal file
24
bin/tests/system/lwresd/lwresd1/nosearch.conf
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2000, 2001, 2004, 2007, 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/.
|
||||
*/
|
||||
|
||||
/* $Id: lwresd.conf,v 1.8 2007/06/19 23:47:04 tbox Exp $ */
|
||||
|
||||
controls { /* empty */ };
|
||||
|
||||
options {
|
||||
port 5300;
|
||||
pid-file "lwresd.pid";
|
||||
forwarders {10.53.0.1;};
|
||||
forward only;
|
||||
};
|
||||
|
||||
lwres {
|
||||
listen-on {10.53.0.1 port 9210;};
|
||||
view "_default";
|
||||
ndots 1;
|
||||
};
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <isc/net.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/string.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
#include <lwres/lwres.h>
|
||||
#include <lwres/netdb.h>
|
||||
@@ -640,12 +641,18 @@ test_getrrsetbyname(const char *name, int rdclass, int rdtype,
|
||||
}
|
||||
|
||||
int
|
||||
main(void) {
|
||||
main(int argc, char **argv) {
|
||||
lwres_result_t ret;
|
||||
int nosearch = 0;
|
||||
|
||||
UNUSED(argc);
|
||||
|
||||
lwres_udp_port = 9210;
|
||||
lwres_resolv_conf = "resolv.conf";
|
||||
|
||||
if (argv[1] != NULL && strcmp(argv[1], "-nosearch") == 0)
|
||||
nosearch = 1;
|
||||
|
||||
ret = lwres_context_create(&ctx, NULL, NULL, NULL, 0);
|
||||
CHECK(ret, "lwres_context_create");
|
||||
|
||||
@@ -664,10 +671,16 @@ main(void) {
|
||||
LWRES_ADDRTYPE_V4);
|
||||
test_gabn("a.example3", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
|
||||
test_gabn("a.example3.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
|
||||
test_gabn("a", LWRES_R_SUCCESS, "10.0.1.1", LWRES_ADDRTYPE_V4);
|
||||
if (nosearch)
|
||||
test_gabn("a", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
|
||||
else
|
||||
test_gabn("a", LWRES_R_SUCCESS, "10.0.1.1", LWRES_ADDRTYPE_V4);
|
||||
test_gabn("a.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
|
||||
|
||||
test_gabn("a2", LWRES_R_SUCCESS, "10.0.1.1", LWRES_ADDRTYPE_V4);
|
||||
if (nosearch)
|
||||
test_gabn("a2", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
|
||||
else
|
||||
test_gabn("a2", LWRES_R_SUCCESS, "10.0.1.1", LWRES_ADDRTYPE_V4);
|
||||
test_gabn("a3", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V4);
|
||||
|
||||
test_gabn("b.example1", LWRES_R_SUCCESS,
|
||||
@@ -684,9 +697,12 @@ main(void) {
|
||||
LWRES_ADDRTYPE_V6);
|
||||
test_gabn("b.example3", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
|
||||
test_gabn("b.example3.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
|
||||
test_gabn("b", LWRES_R_SUCCESS,
|
||||
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
|
||||
LWRES_ADDRTYPE_V6);
|
||||
if (nosearch)
|
||||
test_gabn("b", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
|
||||
else
|
||||
test_gabn("b", LWRES_R_SUCCESS,
|
||||
"eeee:eeee:eeee:eeee:ffff:ffff:ffff:ffff",
|
||||
LWRES_ADDRTYPE_V6);
|
||||
test_gabn("b.", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
|
||||
|
||||
test_gabn("d.example1", LWRES_R_NOTFOUND, NULL, LWRES_ADDRTYPE_V6);
|
||||
@@ -761,7 +777,10 @@ main(void) {
|
||||
test_getnameinfo("1122:3344:5566:7788:99aa:bbcc:ddee:ff00",
|
||||
AF_INET6, "dname.example1");
|
||||
|
||||
test_getrrsetbyname("a", 1, 1, 1, 0, 1);
|
||||
if (nosearch)
|
||||
test_getrrsetbyname("a", 1, 1, 0, 0, 0);
|
||||
else
|
||||
test_getrrsetbyname("a", 1, 1, 1, 0, 1);
|
||||
test_getrrsetbyname("a.example1.", 1, 1, 1, 0, 1);
|
||||
test_getrrsetbyname("e.example1.", 1, 1, 1, 1, 1);
|
||||
test_getrrsetbyname("e.example1.", 1, 255, 1, 1, 0);
|
||||
|
||||
@@ -70,5 +70,24 @@ if [ $ret != 0 ]; then
|
||||
fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
$PERL $SYSTEMTESTTOP/stop.pl . lwresd1
|
||||
|
||||
mv lwresd1/lwresd.run lwresd1/lwresd.run.lwresd
|
||||
|
||||
$PERL $SYSTEMTESTTOP/start.pl . lwresd1 -- "-m record,size,mctx -c nosearch.conf -d 99 -g"
|
||||
|
||||
echo "I:using nosearch.conf"
|
||||
ret=0
|
||||
for i in 0 1 2 3 4 5 6 7 8 9
|
||||
do
|
||||
grep ' running$' lwresd1/lwresd.run > /dev/null && break
|
||||
sleep 1
|
||||
done
|
||||
./lwtest -nosearch || ret=1
|
||||
if [ $ret != 0 ]; then
|
||||
echo "I:failed"
|
||||
fi
|
||||
status=`expr $status + $ret`
|
||||
|
||||
echo "I:exit status: $status"
|
||||
[ $status -eq 0 ] || exit 1
|
||||
|
||||
Reference in New Issue
Block a user