]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4265. [bug] Address unchecked isc_mem_get calls. [RT #41187]
authorMark Andrews <marka@isc.org>
Sun, 29 Nov 2015 23:29:29 +0000 (10:29 +1100)
committerMark Andrews <marka@isc.org>
Sun, 29 Nov 2015 23:29:29 +0000 (10:29 +1100)
CHANGES
lib/dns/openssldsa_link.c
lib/dns/rdata.c
lib/dns/tkey.c
lib/isc/md5.c

diff --git a/CHANGES b/CHANGES
index 06e90008c2156f0dc6950ada9b411e587c4fc779..f9c4c318a680d68efa0046a10a824b33f7f1992a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+4265.  [bug]           Address unchecked isc_mem_get calls. [RT #41187]
+
 4264.  [bug]           Check const of strchr/strrchr assignments match
                        argument's const status. [RT #41150]
 
index d47b265f15700f2bea691ceabdf8989fdf4cf603..af931db4dd3280fb63769fb784c8dc10ef017d2a 100644 (file)
@@ -78,6 +78,8 @@ openssldsa_createctx(dst_key_t *key, dst_context_t *dctx) {
        UNUSED(key);
 
        sha1ctx = isc_mem_get(dctx->mctx, sizeof(isc_sha1_t));
+       if (sha1ctx == NULL)
+               return (ISC_R_NOMEMORY);
        isc_sha1_init(sha1ctx);
        dctx->ctxdata.sha1ctx = sha1ctx;
        return (ISC_R_SUCCESS);
index 107813bbe3b83277428cf80b7d9cf321782258f9..9340b13601cbfb91416664513348513e9609c3af 100644 (file)
@@ -1784,6 +1784,9 @@ static isc_result_t
 mem_tobuffer(isc_buffer_t *target, void *base, unsigned int length) {
        isc_region_t tr;
 
+       if (length == 0U)
+               return (ISC_R_SUCCESS);
+
        isc_buffer_availableregion(target, &tr);
        if (length > tr.length)
                return (ISC_R_NOSPACE);
index a69b4c9bf5aa887a9c6afbb56e7adc8fc318735f..0d204e9db73b68f27981153be88cf47cb7c7d3fa 100644 (file)
@@ -990,7 +990,7 @@ dns_tkey_builddhquery(dns_message_t *msg, dst_key_t *key, dns_name_t *name,
        if (nonce != NULL)
                isc_buffer_usedregion(nonce, &r);
        else {
-               r.base = isc_mem_get(msg->mctx, 0);
+               r.base = NULL;
                r.length = 0;
        }
        tkey.error = 0;
@@ -1001,9 +1001,6 @@ dns_tkey_builddhquery(dns_message_t *msg, dst_key_t *key, dns_name_t *name,
 
        RETERR(buildquery(msg, name, &tkey, ISC_FALSE));
 
-       if (nonce == NULL)
-               isc_mem_put(msg->mctx, r.base, 0);
-
        RETERR(dns_message_gettemprdata(msg, &rdata));
        RETERR(isc_buffer_allocate(msg->mctx, &dynbuf, 1024));
        RETERR(dst_key_todns(key, dynbuf));
@@ -1234,12 +1231,10 @@ dns_tkey_processdhresponse(dns_message_t *qmsg, dns_message_t *rmsg,
        if (nonce != NULL)
                isc_buffer_usedregion(nonce, &r2);
        else {
-               r2.base = isc_mem_get(rmsg->mctx, 0);
+               r2.base = NULL;
                r2.length = 0;
        }
        RETERR(compute_secret(shared, &r2, &r, &secret));
-       if (nonce == NULL)
-               isc_mem_put(rmsg->mctx, r2.base, 0);
 
        isc_buffer_usedregion(&secret, &r);
        result = dns_tsigkey_create(tkeyname, &rtkey.algorithm,
index a83febabcac80900a2a1167373cbd8cca01dfe49..ed23400d532d2b440fb108e01636758a2bd80977 100644 (file)
@@ -62,6 +62,8 @@ isc_md5_invalidate(isc_md5_t *ctx) {
 
 void
 isc_md5_update(isc_md5_t *ctx, const unsigned char *buf, unsigned int len) {
+       if (len == 0U)
+               return;
        RUNTIME_CHECK(EVP_DigestUpdate(ctx,
                                       (const void *) buf,
                                       (size_t) len) == 1);