]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2308. [cleanup] Silence Coverity warning in bin/named/controlconf.c.
authorMark Andrews <marka@isc.org>
Thu, 17 Jan 2008 02:57:16 +0000 (02:57 +0000)
committerMark Andrews <marka@isc.org>
Thu, 17 Jan 2008 02:57:16 +0000 (02:57 +0000)
                        [RT #17495]

CHANGES
bin/named/controlconf.c

diff --git a/CHANGES b/CHANGES
index f78c19741c560aea0a7f63c0d7131076fdaf5a2e..7ede399622e09f9abf7eaa97312f32d8c45e4a58 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2308.  [cleanup]       Silence Coverity warning in bin/named/controlconf.c.
+                       [RT #17495]
+
 2307.  [bug]           Remove infinite loop from lib/dns/sdb.c. [RT #17496]
 
 2306.  [bug]           Remove potential race from lib/dns/resolver.c.
index 741467cc17987e4bfec96f6e033241e442f2c913..3b13504bc956c79149de5d9569952058bd9c52df 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: controlconf.c,v 1.55 2007/09/12 01:09:07 each Exp $ */
+/* $Id: controlconf.c,v 1.56 2008/01/17 02:57:16 marka Exp $ */
 
 /*! \file */
 
@@ -364,9 +364,6 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
        {
                ccregion.rstart = isc_buffer_base(&conn->ccmsg.buffer);
                ccregion.rend = isc_buffer_used(&conn->ccmsg.buffer);
-               if (secret.rstart != NULL)
-                       isc_mem_put(listener->mctx, secret.rstart,
-                                   REGION_SIZE(secret));
                secret.rstart = isc_mem_get(listener->mctx, key->secret.length);
                if (secret.rstart == NULL)
                        goto cleanup;
@@ -375,7 +372,8 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
                result = isccc_cc_fromwire(&ccregion, &request, &secret);
                if (result == ISC_R_SUCCESS)
                        break;
-               else if (result == ISCCC_R_BADAUTH) {
+               isc_mem_put(listener->mctx, secret.rstart, REGION_SIZE(secret));
+               if (result == ISCCC_R_BADAUTH) {
                        /*
                         * For some reason, request is non-NULL when
                         * isccc_cc_fromwire returns ISCCC_R_BADAUTH.
@@ -396,7 +394,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
        /* We shouldn't be getting a reply. */
        if (isccc_cc_isreply(request)) {
                log_invalid(&conn->ccmsg, ISC_R_FAILURE);
-               goto cleanup;
+               goto cleanup_request;
        }
 
        isc_stdtime_get(&now);
@@ -407,17 +405,17 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
        _ctrl = isccc_alist_lookup(request, "_ctrl");
        if (_ctrl == NULL) {
                log_invalid(&conn->ccmsg, ISC_R_FAILURE);
-               goto cleanup;
+               goto cleanup_request;
        }
 
        if (isccc_cc_lookupuint32(_ctrl, "_tim", &sent) == ISC_R_SUCCESS) {
                if ((sent + CLOCKSKEW) < now || (sent - CLOCKSKEW) > now) {
                        log_invalid(&conn->ccmsg, ISCCC_R_CLOCKSKEW);
-                       goto cleanup;
+                       goto cleanup_request;
                }
        } else {
                log_invalid(&conn->ccmsg, ISC_R_FAILURE);
-               goto cleanup;
+               goto cleanup_request;
        }
 
        /*
@@ -426,7 +424,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
        if (isccc_cc_lookupuint32(_ctrl, "_exp", &exp) == ISC_R_SUCCESS &&
            now > exp) {
                log_invalid(&conn->ccmsg, ISCCC_R_EXPIRED);
-               goto cleanup;
+               goto cleanup_request;
        }
 
        /*
@@ -438,14 +436,14 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
                if (result == ISC_R_EXISTS)
                         result = ISCCC_R_DUPLICATE; 
                log_invalid(&conn->ccmsg, result);
-               goto cleanup;
+               goto cleanup_request;
        }
 
        if (conn->nonce != 0 &&
            (isccc_cc_lookupuint32(_ctrl, "_nonce", &nonce) != ISC_R_SUCCESS ||
             conn->nonce != nonce)) {
                log_invalid(&conn->ccmsg, ISCCC_R_BADAUTH);
-               goto cleanup;
+               goto cleanup_request;
        }
 
        /*
@@ -459,7 +457,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
 
        result = isccc_cc_createresponse(request, now, now + 60, &response);
        if (result != ISC_R_SUCCESS)
-               goto cleanup;
+               goto cleanup_request;
        if (eresult != ISC_R_SUCCESS) {
                isccc_sexpr_t *data;
 
@@ -467,7 +465,7 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
                if (data != NULL) {
                        const char *estr = isc_result_totext(eresult);
                        if (isccc_cc_definestring(data, "err", estr) == NULL)
-                               goto cleanup;
+                               goto cleanup_response;
                }
        }
 
@@ -478,20 +476,20 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
                if (data != NULL) {
                        char *str = (char *)isc_buffer_base(&text);
                        if (isccc_cc_definestring(data, "text", str) == NULL)
-                               goto cleanup;
+                               goto cleanup_response;
                }
        }
 
        _ctrl = isccc_alist_lookup(response, "_ctrl");
        if (_ctrl == NULL ||
            isccc_cc_defineuint32(_ctrl, "_nonce", conn->nonce) == NULL)
-               goto cleanup;
+               goto cleanup_response;
 
        ccregion.rstart = conn->buffer + 4;
        ccregion.rend = conn->buffer + sizeof(conn->buffer);
        result = isccc_cc_towire(response, &ccregion, &secret);
        if (result != ISC_R_SUCCESS)
-               goto cleanup;
+               goto cleanup_response;
        isc_buffer_init(&b, conn->buffer, 4);
        len = sizeof(conn->buffer) - REGION_SIZE(ccregion);
        isc_buffer_putuint32(&b, len - 4);
@@ -500,31 +498,27 @@ control_recvmessage(isc_task_t *task, isc_event_t *event) {
 
        result = isc_socket_send(conn->sock, &r, task, control_senddone, conn);
        if (result != ISC_R_SUCCESS)
-               goto cleanup;
+               goto cleanup_response;
        conn->sending = ISC_TRUE;
 
-       if (secret.rstart != NULL)
-               isc_mem_put(listener->mctx, secret.rstart,
-                           REGION_SIZE(secret));
-       if (request != NULL)
-               isccc_sexpr_free(&request);
-       if (response != NULL)
-               isccc_sexpr_free(&response);
+       isc_mem_put(listener->mctx, secret.rstart, REGION_SIZE(secret));
+       isccc_sexpr_free(&request);
+       isccc_sexpr_free(&response);
        return;
 
+ cleanup_response:
+       isccc_sexpr_free(&response);
+
+ cleanup_request:
+       isccc_sexpr_free(&request);
+       isc_mem_put(listener->mctx, secret.rstart, REGION_SIZE(secret));
+
  cleanup:
-       if (secret.rstart != NULL)
-               isc_mem_put(listener->mctx, secret.rstart,
-                           REGION_SIZE(secret));
        isc_socket_detach(&conn->sock);
        isccc_ccmsg_invalidate(&conn->ccmsg);
        conn->ccmsg_valid = ISC_FALSE;
        maybe_free_connection(conn);
        maybe_free_listener(listener);
-       if (request != NULL)
-               isccc_sexpr_free(&request);
-       if (response != NULL)
-               isccc_sexpr_free(&response);
 }
 
 static void