From b4e114e3cd99b8875fc677a1a1c7c8257ef5a7a6 Mon Sep 17 00:00:00 2001 From: Mukund Sivaraman Date: Tue, 23 Jun 2015 13:57:33 +0530 Subject: [PATCH] Print unsigned values for serial, etc. in rndc zonestatus output (#39854) --- CHANGES | 4 ++++ bin/named/server.c | 6 +++--- bin/tests/system/zonechecks/bigserial.db | 17 +++++++++++++++++ bin/tests/system/zonechecks/ns1/named.conf | 5 +++++ bin/tests/system/zonechecks/setup.sh | 1 + bin/tests/system/zonechecks/tests.sh | 9 ++++++++- 6 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 bin/tests/system/zonechecks/bigserial.db diff --git a/CHANGES b/CHANGES index b0c5d0c1df..6f6fb2e61a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4140. [bug] A formatting bug caused rndc showzone to print + negative numbers for large serial values. This has + now been fixed. [RT #39854] + 4140. [cleanup] Remove redundant nzf_remove() call during delzone. [RT #39844] diff --git a/bin/named/server.c b/bin/named/server.c index 9db6caa48d..ca850f3613 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -10247,15 +10247,15 @@ ns_server_zonestatus(ns_server_t *server, char *args, isc_buffer_t **text) { /* Serial number */ serial = dns_zone_getserial(hasraw ? raw : zone); - snprintf(serbuf, sizeof(serbuf), "%d", serial); + snprintf(serbuf, sizeof(serbuf), "%u", serial); if (hasraw) { signed_serial = dns_zone_getserial(zone); - snprintf(sserbuf, sizeof(sserbuf), "%d", signed_serial); + snprintf(sserbuf, sizeof(sserbuf), "%u", signed_serial); } /* Database node count */ nodes = dns_db_nodecount(hasraw ? rawdb : db); - snprintf(nodebuf, sizeof(nodebuf), "%d", nodes); + snprintf(nodebuf, sizeof(nodebuf), "%u", nodes); /* Security */ secure = dns_db_issecure(db); diff --git a/bin/tests/system/zonechecks/bigserial.db b/bin/tests/system/zonechecks/bigserial.db new file mode 100644 index 0000000000..bdff8ec382 --- /dev/null +++ b/bin/tests/system/zonechecks/bigserial.db @@ -0,0 +1,17 @@ +; Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") +; +; Permission to use, copy, modify, and/or distribute this software for any +; purpose with or without fee is hereby granted, provided that the above +; copyright notice and this permission notice appear in all copies. +; +; THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +; AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +; PERFORMANCE OF THIS SOFTWARE. + +@ 3600 IN SOA ns hostmaster 3003113544 3600 1200 604800 3600 +@ 3600 IN NS ns +ns 3600 IN A 10.53.0.1 diff --git a/bin/tests/system/zonechecks/ns1/named.conf b/bin/tests/system/zonechecks/ns1/named.conf index 4d1983cd35..592b28cc42 100644 --- a/bin/tests/system/zonechecks/ns1/named.conf +++ b/bin/tests/system/zonechecks/ns1/named.conf @@ -61,6 +61,11 @@ view primary { auto-dnssec maintain; }; + zone "bigserial.example" { + type master; + file "bigserial.db"; + }; + zone "reload.example" { type master; file "reload.db"; diff --git a/bin/tests/system/zonechecks/setup.sh b/bin/tests/system/zonechecks/setup.sh index 0a6c0f6ac2..7f524f59fe 100644 --- a/bin/tests/system/zonechecks/setup.sh +++ b/bin/tests/system/zonechecks/setup.sh @@ -23,6 +23,7 @@ test -r $RANDFILE || $GENRANDOM 400 $RANDFILE $SHELL ../genzone.sh 1 > ns1/master.db $SHELL ../genzone.sh 1 > ns1/duplicate.db +cp bigserial.db ns1/ cd ns1 touch master.db.signed echo '$INCLUDE "master.db.signed"' >> master.db diff --git a/bin/tests/system/zonechecks/tests.sh b/bin/tests/system/zonechecks/tests.sh index a1676e0dea..f68c036c5c 100644 --- a/bin/tests/system/zonechecks/tests.sh +++ b/bin/tests/system/zonechecks/tests.sh @@ -171,7 +171,7 @@ done checkfor() { grep "$1" $2 > /dev/null || { ret=1; - echo "I: missing '$1' from '$2'" + echo "I: missing string '$1' from '$2'" } } checkfor "name: master.example" rndc.out.master @@ -246,5 +246,12 @@ checkfor "no matching zone 'nosuchzone.example' in any view" rndc.out.duplicate if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` +echo "I: checking 'rdnc zonestatus' with big serial value" +ret=0 +$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus bigserial.example > rndc.out.bigserial 2>&1 +checkfor "serial: 3003113544" rndc.out.bigserial +if [ $ret != 0 ]; then echo "I:failed"; fi +status=`expr $status + $ret` + echo "I:exit status: $status" exit $status