]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove canary code from hash destroy function (#38602)
authorMukund Sivaraman <muks@isc.org>
Thu, 12 Feb 2015 12:44:34 +0000 (18:14 +0530)
committerMukund Sivaraman <muks@isc.org>
Thu, 12 Feb 2015 12:49:33 +0000 (18:19 +0530)
This triggers a Valgrind out-of-bounds read report. It was introduced by
commit 5d7849ad7ffc6d08870dbfbc8d6bfffd90007488.

No CHANGES entry necessary as it doesn't have any user-visible or
behavioral change. It removes an out-of-bounds read issue that went
undetected when allocated through isc_mem as the memory was present.
The memory read was compared to itself, so it has no behavioral change.

(cherry picked from commit ffc393dd180f9e3b300a160f1e26cbc1c2239f54)

lib/isc/hash.c

index e12c47183f21cb51d55f9b8a6a5fb5641ec042b6..b69ca3f6653e5e9699b21becc52dab063ca36681 100644 (file)
@@ -302,7 +302,6 @@ static void
 destroy(isc_hash_t **hctxp) {
        isc_hash_t *hctx;
        isc_mem_t *mctx;
-       unsigned char canary0[4], canary1[4];
 
        REQUIRE(hctxp != NULL && *hctxp != NULL);
        hctx = *hctxp;
@@ -324,10 +323,7 @@ destroy(isc_hash_t **hctxp) {
 
        DESTROYLOCK(&hctx->lock);
 
-       memmove(canary0, hctx + 1, sizeof(canary0));
        memset(hctx, 0, sizeof(isc_hash_t));
-       memmove(canary1, hctx + 1, sizeof(canary1));
-       INSIST(memcmp(canary0, canary1, sizeof(canary0)) == 0);
        isc_mem_put(mctx, hctx, sizeof(isc_hash_t));
        isc_mem_detach(&mctx);
 }