From b0c18fffd3c81d3cb617dbba4d222d49ae266f28 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 6 Jan 2015 11:31:34 +1100 Subject: [PATCH] 4028. [bug] $GENERATE with a zero step was not being caught as a error. A $GENERATE with a / but no step was not being caught as a error. [RT #38262] --- CHANGES | 4 ++++ bin/tests/system/checkzone/zones/bad3.db | 22 ++++++++++++++++++++++ bin/tests/system/checkzone/zones/bad4.db | 22 ++++++++++++++++++++++ lib/dns/master.c | 7 ++++--- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 bin/tests/system/checkzone/zones/bad3.db create mode 100644 bin/tests/system/checkzone/zones/bad4.db diff --git a/CHANGES b/CHANGES index 467a3ba6ba..fb869c3153 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4028. [bug] $GENERATE with a zero step was not being caught as a + error. A $GENERATE with a / but no step was not being + caught as a error. [RT #38262] + 4027. [port] Net::DNS 0.81 compatibility. [RT #38165] 4026. [bug] Fix RFC 3658 reference in dig +sigchase. [RT #38173] diff --git a/bin/tests/system/checkzone/zones/bad3.db b/bin/tests/system/checkzone/zones/bad3.db new file mode 100644 index 0000000000..4fef8433fa --- /dev/null +++ b/bin/tests/system/checkzone/zones/bad3.db @@ -0,0 +1,22 @@ +; Copyright (C) 2015 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. + +$TTL 600 +@ SOA ns hostmaster 2011012708 3600 1200 604800 1200 + NS ns +ns A 192.0.2.1 +; +; A trailing '/' is not permitted. +; +$GENERATE 1-3/ $ A 1.2.3.$ diff --git a/bin/tests/system/checkzone/zones/bad4.db b/bin/tests/system/checkzone/zones/bad4.db new file mode 100644 index 0000000000..efb7df54a0 --- /dev/null +++ b/bin/tests/system/checkzone/zones/bad4.db @@ -0,0 +1,22 @@ +; Copyright (C) 2015 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. + +$TTL 600 +@ SOA ns hostmaster 2011012708 3600 1200 604800 1200 + NS ns +ns A 192.0.2.1 +; +; A step of zero is not permitted. +; +$GENERATE 1-3/0 $ A 1.2.3.$ diff --git a/lib/dns/master.c b/lib/dns/master.c index 2d14c58b8c..26c9d35b5f 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -819,6 +819,7 @@ generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs, isc_textregion_t r; int i, n, start, stop, step = 0; dns_incctx_t *ictx; + char dummy; ictx = lctx->inc; callbacks = lctx->callbacks; @@ -835,9 +836,9 @@ generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs, } isc_buffer_init(&target, target_mem, target_size); - n = sscanf(range, "%d-%d/%d", &start, &stop, &step); - if ((n < 2) || (start < 0) || (stop < 0) || (step < 0) || - (stop < start)) + n = sscanf(range, "%d-%d%[/]%d", &start, &stop, &dummy, &step); + if ((n != 2 && n != 4) || (start < 0) || (stop < 0) || + (n == 4 && step < 1) || (stop < start)) { (*callbacks->error)(callbacks, "%s: %s:%lu: invalid range '%s'",