]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
address memory leak with bad tsig secret
authorEvan Hunt <each@isc.org>
Sat, 11 Aug 2012 03:16:59 +0000 (20:16 -0700)
committerEvan Hunt <each@isc.org>
Sat, 11 Aug 2012 03:16:59 +0000 (20:16 -0700)
3359. [bug] An improperly-formed TSIG secret could cause a
                        memory leak. [RT #30607]

CHANGES
bin/tests/system/checkconf/badtsig.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh
lib/bind9/check.c

diff --git a/CHANGES b/CHANGES
index 93ec211975db124e129633da7fd9a7644ab91495..ad8df708824c02b7f130d0afbd0567a43384827c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3359.  [bug]           An improperly-formed TSIG secret could cause a
+                        memory leak. [RT #30607]
+
 3357.  [port]          Add support for libxml2-2.8.x [RT #30440]
 
 3356.  [bug]           Cap the TTL of signed RRsets when RRSIGs are 
diff --git a/bin/tests/system/checkconf/badtsig.conf b/bin/tests/system/checkconf/badtsig.conf
new file mode 100644 (file)
index 0000000..9585b11
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2012  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.
+ */
+
+/* Bad secret */
+key "badtsig" {
+       algorithm hmac-md5;
+       secret "jEdD+BPKg==";
+};
+
index de088cb35b7290373a749d09dd9e61a521f7f68e..52988522793ee459173c93f59e9cce6886da4b4a 100644 (file)
@@ -37,7 +37,13 @@ status=`expr $status + $ret`
 echo "I: checking that named-checkconf handles a known bad config"
 ret=0
 $CHECKCONF bad.conf > /dev/null 2>&1 && ret=1
-if [ $ret != 0 ]; then echo "I:failed"; fi
+if [ $? != 1 ]; then echo "I:failed"; ret=1; fi
+status=`expr $status + $ret`
+
+echo "I: checking that named-checkconf handles a known bad tsig secret"
+ret=0
+$CHECKCONF badtsig.conf > /dev/null 2>&1
+if [ $? != 1 ]; then echo "I:failed"; ret=1; fi
 status=`expr $status + $ret`
 
 echo "I: checking named-checkconf dnssec warnings"
index 3273c560fe9a66203781cc0cdbcf4e17f892b551..356ad6d88ca9bd8632f5ac3e610151291537125c 100644 (file)
@@ -2226,15 +2226,15 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
        tresult = isc_symtab_create(mctx, 1000, freekey, mctx,
                                    ISC_FALSE, &symtab);
        if (tresult != ISC_R_SUCCESS)
-               return (ISC_R_NOMEMORY);
+               goto cleanup;
 
        (void)cfg_map_get(config, "key", &keys);
        tresult = check_keylist(keys, symtab, mctx, logctx);
        if (tresult == ISC_R_EXISTS)
                result = ISC_R_FAILURE;
        else if (tresult != ISC_R_SUCCESS) {
-               isc_symtab_destroy(&symtab);
-               return (tresult);
+               result = tresult;
+               goto cleanup;
        }
 
        if (voptions != NULL) {
@@ -2244,8 +2244,8 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
                if (tresult == ISC_R_EXISTS)
                        result = ISC_R_FAILURE;
                else if (tresult != ISC_R_SUCCESS) {
-                       isc_symtab_destroy(&symtab);
-                       return (tresult);
+                       result = tresult;
+                       goto cleanup;
                }
        }
 
@@ -2366,7 +2366,11 @@ check_viewconf(const cfg_obj_t *config, const cfg_obj_t *voptions,
        if (tresult != ISC_R_SUCCESS)
                result = tresult;
 
-       cfg_aclconfctx_detach(&actx);
+ cleanup:
+       if (symtab != NULL)
+               isc_symtab_destroy(&symtab);
+       if (actx != NULL)
+               cfg_aclconfctx_detach(&actx);
 
        return (result);
 }