From d1a9e549b1a47352fca00bfb72b317bfbd4e8e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 12 Jul 2021 08:43:14 +0200 Subject: [PATCH] Fix the real allocation size in OpenBSD rallocx shim In the rallocx() shim for OpenBSD (that's the only platform that doesn't have malloc_size() or malloc_usable_size() equivalent), the newly allocated size was missing the extra size_t member for storing the allocation size leading to size_t sized overflow at the end of the reallocated memory chunk. --- lib/isc/jemalloc_shim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/isc/jemalloc_shim.h b/lib/isc/jemalloc_shim.h index 11f8099661..d04ac22ac3 100644 --- a/lib/isc/jemalloc_shim.h +++ b/lib/isc/jemalloc_shim.h @@ -106,7 +106,7 @@ static inline void * rallocx(void *ptr, size_t size, int flags) { UNUSED(flags); - size_t *__ptr = realloc(&((size_t *)ptr)[-1], size); + size_t *__ptr = realloc(&((size_t *)ptr)[-1], size + sizeof(size_t)); REQUIRE(__ptr != NULL); __ptr[0] = size;