]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix a bug in the duration_fromtext function
authorMatthijs Mekking <matthijs@isc.org>
Fri, 24 Jun 2022 07:58:40 +0000 (09:58 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Tue, 28 Jun 2022 09:56:31 +0000 (11:56 +0200)
The function actually did not enforce that the duration string starts
with a P (or p), just that there is a P (or p) in the string.

bin/tests/system/checkconf/bad-duration.conf [new file with mode: 0644]
lib/isccfg/duration.c

diff --git a/bin/tests/system/checkconf/bad-duration.conf b/bin/tests/system/checkconf/bad-duration.conf
new file mode 100644 (file)
index 0000000..1fbecc7
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * 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 https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+dnssec-policy "test" {
+       dnskey-ttl xPT1H;
+};
index 30d110ab0a71772b6bd6293aa4233c22c079a180..0a7501b0222d63153bc5e679cbe2c4a17391dea9 100644 (file)
@@ -61,10 +61,10 @@ isccfg_duration_fromtext(isc_textregion_t *source,
        duration->unlimited = false;
 
        /* Every duration starts with 'P' */
-       P = strpbrk(str, "Pp");
-       if (P == NULL) {
+       if (toupper(str[0]) != 'P') {
                return (ISC_R_BADNUMBER);
        }
+       P = str;
 
        /* Record the time indicator. */
        T = strpbrk(str, "Tt");