]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4766. [cleanup] Addresss Coverity warnings. [RT #46150]
authorMark Andrews <marka@isc.org>
Mon, 9 Oct 2017 07:34:31 +0000 (18:34 +1100)
committerMark Andrews <marka@isc.org>
Mon, 9 Oct 2017 07:34:31 +0000 (18:34 +1100)
4765.   [bug]           Address potential INSIST in dnssec-cds. [RT #46150]

CHANGES
bin/dnssec/dnssec-cds.c
lib/irs/getnameinfo.c
lib/ns/query.c

diff --git a/CHANGES b/CHANGES
index 50774d602d242ebdb2a44777a2519d8c01eccaaf..28e7a721e4178b6f94565b83974adbd18101f0b0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+4766.  [cleanup]       Addresss Coverity warnings. [RT #46150]
+
+4765.  [bug]           Address potential INSIST in dnssec-cds. [RT #46150]
+
 4764.  [bug]           Address portability issues in cds system test.
                        [RT #46214]
 
index 521f7bd7aae9dcedda86cc180d47aa2ffc10d5ea..56237823c17819c0eb8b9c0d283c5c389fd303ad 100644 (file)
@@ -360,13 +360,14 @@ load_parent_set(const char *path) {
        free_db(&db, &node);
 }
 
+#define MAX_CDS_RDATA_TEXT_SIZE DNS_RDATA_MAXLENGTH * 2
+
 static isc_buffer_t *
 formatset(dns_rdataset_t *rdataset) {
        isc_result_t result;
        isc_buffer_t *buf = NULL;
        dns_master_style_t *style = NULL;
        unsigned int styleflags;
-       unsigned int size;
 
        styleflags = (rdataset->ttl == 0) ? DNS_STYLEFLAG_NO_TTL : 0;
 
@@ -378,23 +379,17 @@ formatset(dns_rdataset_t *rdataset) {
        result = dns_master_stylecreate2(&style, styleflags,
                                         0, 0, 0, 0, 0, 1000000, 0,
                                         mctx);
+       check_result(result, "dns_master_stylecreate2 failed");
 
-       size = 256;
-       do {
-               result = isc_buffer_allocate(mctx, &buf, size);
-               check_result(result, "printing DS records");
-               result = dns_master_rdatasettotext(name, rdataset,
-                                                  style, buf);
-               if (result == ISC_R_NOSPACE ||
-                   isc_buffer_availablelength(buf) < 1)
-               {
-                       vbprintf(20, "formatset buffer size %u\n", size);
-                       isc_buffer_free(&buf);
-                       size *= 2;
-               } else {
-                       check_result(result, "dns_rdataset_totext()");
-               }
-       } while (result != ISC_R_SUCCESS);
+       result = isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
+       check_result(result, "printing DS records");
+       result = dns_master_rdatasettotext(name, rdataset, style, buf);
+
+       if ((result == ISC_R_SUCCESS) && isc_buffer_availablelength(buf) < 1) {
+               result = ISC_R_NOSPACE;
+       }
+
+       check_result(result, "dns_rdataset_totext()");
 
        isc_buffer_putuint8(buf, 0);
 
index 1134a1acd8e971dfc5c7bc06a65b0d5ed38c2fc0..c5f987dd7563e1612ec6778b26fc4ac63e0de081 100644 (file)
@@ -320,6 +320,7 @@ getnameinfo(const struct sockaddr *sa, IRS_GETNAMEINFO_SOCKLEN_T salen,
                case DNS_R_NOVALIDDS:
                case DNS_R_NOVALIDSIG:
                        ERR(EAI_INSECUREDATA);
+                       /* NOTREACHED */
                default:
                        ERR(EAI_FAIL);
                }
index ee156efe6a31548db11542629804aa85314ea812..7e19ff06fc12287d0f4212a2805f8091f0243b9e 100644 (file)
@@ -8353,7 +8353,6 @@ query_synthnodata(query_ctx_t *qctx, const dns_name_t *signer,
        dns_ttl_t ttl;
        isc_buffer_t *dbuf, b;
        isc_result_t result;
-       dns_rdataset_t *clone = NULL, *sigclone = NULL;
 
        /*
         * Detemine the correct TTL to use for the SOA and RRSIG
@@ -8413,12 +8412,6 @@ cleanup:
        if (name != NULL) {
                query_releasename(qctx->client, &name);
        }
-       if (clone != NULL) {
-               query_putrdataset(qctx->client, &clone);
-       }
-       if (sigclone != NULL) {
-               query_putrdataset(qctx->client, &sigclone);
-       }
        return (result);
 }
 
@@ -8746,7 +8739,6 @@ query_coveringnsec(query_ctx_t *qctx) {
        dns_fixedname_t fsigner;
        dns_fixedname_t fwild;
        dns_name_t *fname = NULL;
-       dns_name_t *name = NULL;
        dns_name_t *nowild = NULL;
        dns_name_t *signer = NULL;
        dns_name_t *wild = NULL;
@@ -8891,6 +8883,7 @@ query_coveringnsec(query_ctx_t *qctx) {
                {
                        goto cleanup;
                }
+               /* FALLTHROUGH */
        case DNS_R_CNAME:
                if (!qctx->resuming && !STALE(&rdataset) &&
                    rdataset.ttl == 0 && RECURSIONOK(qctx->client))
@@ -8997,9 +8990,6 @@ query_coveringnsec(query_ctx_t *qctx) {
                }
                dns_db_detach(&db);
        }
-       if (name != NULL) {
-               query_releasename(qctx->client, &name);
-       }
 
        if (redirected) {
                return (result);