]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4028. [bug] $GENERATE with a zero step was not being caught as a
authorMark Andrews <marka@isc.org>
Tue, 6 Jan 2015 00:31:34 +0000 (11:31 +1100)
committerMark Andrews <marka@isc.org>
Tue, 6 Jan 2015 00:31:34 +0000 (11:31 +1100)
                        error.  A $GENERATE with a / but no step was not being
                        caught as a error. [RT #38262]

CHANGES
bin/tests/system/checkzone/zones/bad3.db [new file with mode: 0644]
bin/tests/system/checkzone/zones/bad4.db [new file with mode: 0644]
lib/dns/master.c

diff --git a/CHANGES b/CHANGES
index 467a3ba6ba05f9c0ef98a7e6e242057f010ee4ec..fb869c3153762e125a89bd068062f92dacb7fa2e 100644 (file)
--- 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 (file)
index 0000000..4fef843
--- /dev/null
@@ -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 (file)
index 0000000..efb7df5
--- /dev/null
@@ -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.$
index 2d14c58b8cf2492e530011b7ebe7c6abfd211d54..26c9d35b5fcb249c6dba41b328adc40749145dd4 100644 (file)
@@ -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'",