From: Ondřej Surý Date: Fri, 5 Feb 2021 16:18:28 +0000 (+0100) Subject: Remove overrun checking code from memory allocator X-Git-Tag: v9.17.11~40^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ff47b47f1a32e7e5c6380bf199e146f03a81edc2;p=thirdparty%2Fbind9.git Remove overrun checking code from memory allocator The ISC_MEM_CHECKOVERRUN would add canary byte at the end of every allocations and check whether the canary byte hasn't been changed at the free time. The AddressSanitizer and valgrind memory checks surpases simple checks like this, so there's no need to actually keep the code inside the allocator. --- diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 103667a0879..9f6db548230 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -339,9 +339,6 @@ static inline void * mem_get(isc_mem_t *ctx, size_t size) { char *ret; -#if ISC_MEM_CHECKOVERRUN - size += 1; -#endif /* if ISC_MEM_CHECKOVERRUN */ ret = default_memalloc(size); if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) { @@ -349,14 +346,6 @@ mem_get(isc_mem_t *ctx, size_t size) { memset(ret, 0xbe, size); /* Mnemonic for "beef". */ } } -#if ISC_MEM_CHECKOVERRUN - else - { - if (ISC_LIKELY(ret != NULL)) { - ret[size - 1] = 0xbe; - } - } -#endif /* if ISC_MEM_CHECKOVERRUN */ return (ret); } @@ -367,10 +356,6 @@ mem_get(isc_mem_t *ctx, size_t size) { /* coverity[+free : arg-1] */ static inline void mem_put(isc_mem_t *ctx, void *mem, size_t size) { -#if ISC_MEM_CHECKOVERRUN - INSIST(((unsigned char *)mem)[size] == 0xbe); - size += 1; -#endif /* if ISC_MEM_CHECKOVERRUN */ if (ISC_UNLIKELY((ctx->flags & ISC_MEMFLAG_FILL) != 0)) { memset(mem, 0xde, size); /* Mnemonic for "dead". */ }