]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fixes for several errors found by Coverity. [rt17160]
authorEvan Hunt <each@isc.org>
Mon, 24 Sep 2007 17:18:25 +0000 (17:18 +0000)
committerEvan Hunt <each@isc.org>
Mon, 24 Sep 2007 17:18:25 +0000 (17:18 +0000)
CHANGES
lib/bind/dst/dst_api.c
lib/bind/dst/hmac_link.c
lib/dns/tsig.c
lib/isc/radix.c
lib/lwres/lwres_gnba.c

diff --git a/CHANGES b/CHANGES
index f7bbc72fe65eac82696cb6478afea7333d81ceb2..b6a09ffa0129854b71e665d58a3c2be54d7bf96e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+2248.   [cleanup]       Fix several errors reported by Coverity. [RT #17160]
+
 2247.  [doc]           Sort doc/misc/options. [RT #17067]
 
 2246.  [bug]           Make the startup of test servers (ans.pl) more
index d3976ef543d0d63491eb641060544b51b5fced01..7ff5d13ca48294df672e75953a3a8b5bb216c91f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef LINT
-static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/dst_api.c,v 1.16 2007/08/27 03:32:26 marka Exp $";
+static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/dst_api.c,v 1.17 2007/09/24 17:18:25 each Exp $";
 #endif
 
 /*
@@ -434,6 +434,7 @@ dst_s_write_private_key(const DST_KEY *key)
                if ((nn = fwrite(encoded_block, 1, len, fp)) != len) {
                        EREPORT(("dst_write_private_key(): Write failure on %s %d != %d errno=%d\n",
                                 file, len, nn, errno));
+                       fclose(fp);
                        return (-5);
                }
                fclose(fp);
index eca5f01353a5259f06e6d9138497882f329d435f..23e4bb6e6d5de75d7188631594ebeac72868fc15 100644 (file)
@@ -1,6 +1,6 @@
 #ifdef HMAC_MD5
 #ifndef LINT
-static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/hmac_link.c,v 1.7 2007/02/26 01:51:43 marka Exp $";
+static const char rcsid[] = "$Header: /u0/home/explorer/proj/ISC/git-conversion/cvsroot/bind9/lib/bind/dst/Attic/hmac_link.c,v 1.8 2007/09/24 17:18:25 each Exp $";
 #endif
 /*
  * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@@ -223,6 +223,7 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
        HMAC_Key *hkey = NULL;
        MD5_CTX ctx;
        int local_keylen = keylen;
+       u_char tk[MD5_LEN];
 
        if (dkey == NULL || key == NULL || keylen < 0)
                return (-1);
@@ -235,7 +236,6 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
 
        /* if key is longer than HMAC_LEN bytes reset it to key=MD5(key) */
        if (keylen > HMAC_LEN) {
-               u_char tk[MD5_LEN];
                MD5Init(&ctx);
                MD5Update(&ctx, key, keylen);
                MD5Final(tk, &ctx);
index f1391e52da188bb1a8d8cfa3e4e7afcb2fe6f580..5ab20a348c0f22a80f5728e8bd4e5a11288572ea 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 /*
- * $Id: tsig.c,v 1.129 2007/06/19 23:47:16 tbox Exp $
+ * $Id: tsig.c,v 1.130 2007/09/24 17:18:25 each Exp $
  */
 /*! \file */
 #include <config.h>
@@ -1512,8 +1512,10 @@ dns_tsigkeyring_create(isc_mem_t *mctx, dns_tsig_keyring_t **ringp) {
                return (ISC_R_NOMEMORY);
 
        result = isc_rwlock_init(&ring->lock, 0, 0);
-       if (result != ISC_R_SUCCESS)
+       if (result != ISC_R_SUCCESS) {
+               isc_mem_put(mctx, ring, sizeof(dns_tsig_keyring_t));
                return (result);
+       }
 
        ring->keys = NULL;
        result = dns_rbt_create(mctx, free_tsignode, NULL, &ring->keys);
index a5f21661973e77aa52e76da41d07f5e31f5decf4..e35195e87ffee93747cc0d880ab7e092100390a5 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: radix.c,v 1.5 2007/09/19 03:03:29 marka Exp $ */
+/* $Id: radix.c,v 1.6 2007/09/24 17:18:25 each Exp $ */
 
 /*
  * This source was adapted from MRT's RCS Ids:
@@ -289,13 +289,15 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
        isc_uint32_t i, j, r;
        isc_result_t result;
 
-       REQUIRE(radix);
-       REQUIRE(prefix || (source && source->prefix));
-       RUNTIME_CHECK(prefix->bitlen <= radix->maxbits);
+       REQUIRE(radix != NULL);
+       REQUIRE(prefix != NULL || (source != NULL && source->prefix != NULL));
+       RUNTIME_CHECK(prefix == NULL || prefix->bitlen <= radix->maxbits);
 
-       if (!prefix && source && source->prefix)
+       if (prefix == NULL)
                prefix = source->prefix;
 
+       INSIST(prefix != NULL);
+
        if (radix->head == NULL) {
                node = isc_mem_get(radix->mctx, sizeof(isc_radix_node_t));
                if (node == NULL)
@@ -338,7 +340,7 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
                INSIST(node != NULL);
        }
 
-       INSIST(node->prefix);
+       INSIST(node->prefix != NULL);
 
        test_addr = isc_prefix_touchar(node->prefix);
        /* Find the first bit different. */
@@ -364,13 +366,13 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
                differ_bit = check_bit;
 
        parent = node->parent;
-       while (parent && parent->bit >= differ_bit) {
+       while (parent != NULL && parent->bit >= differ_bit) {
                node = parent;
                parent = node->parent;
        }
 
        if (differ_bit == bitlen && node->bit == bitlen) {
-               if (node->prefix) {
+               if (node->prefix != NULL) {
                        *target = node;
                        return (ISC_R_SUCCESS);
                }
@@ -406,7 +408,7 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
        new_node->l = new_node->r = NULL;
        radix->num_active_node++;
 
-       if (source) {
+       if (source != NULL) {
                /*
                 * If source is non-NULL, then we're merging in a node
                 * from an existing radix tree.  Node_num values have to
index 7843fc3257daa69fcbefc24ea00e583a008f120d..d18ae153f23e0314fba8877eff738e95e1744750 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: lwres_gnba.c,v 1.27 2007/06/19 23:47:22 tbox Exp $ */
+/* $Id: lwres_gnba.c,v 1.28 2007/09/24 17:18:25 each Exp $ */
 
 /*! \file lwres_gnba.c
    These are low-level routines for creating and parsing lightweight
@@ -126,7 +126,6 @@ lwres_gnbarequest_render(lwres_context_t *ctx, lwres_gnbarequest_t *req,
        REQUIRE(req != NULL);
        REQUIRE(req->addr.family != 0);
        REQUIRE(req->addr.length != 0);
-       REQUIRE(req->addr.address != NULL);
        REQUIRE(pkt != NULL);
        REQUIRE(b != NULL);