summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2020-04-18 15:17:33 -0700
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2020-04-18 15:17:33 -0700
commit1a22178a4dea836dac7403cee3f74375dd2c9bbd (patch)
tree89c777c6e1f58e829658c069a20f46956ad78745
parent614406260e86408fb42edc2cea1a7bb5cac20906 (diff)
downloadsecret-memory-preloader-1a22178a4dea836dac7403cee3f74375dd2c9bbd.tar.gz
Add check for chunk minsize
-rw-r--r--preload.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/preload.c b/preload.c
index 45d4a37..4834036 100644
--- a/preload.c
+++ b/preload.c
@@ -49,7 +49,7 @@ struct malloc_chunk {
};
#define CHUNK_SIZE (sizeof(struct malloc_chunk_head))
-#define MIN_CHUNK 0x10
+#define MIN_CHUNK 0x20
#define CHUNK_ALIGNMENT (MIN_CHUNK - 1)
struct segptr {
@@ -233,6 +233,13 @@ static void alloc_segment(void)
void __attribute__ ((constructor)) preload_setup(void)
{
+ /*
+ * if this fails, the MIN_CHUNK, which must be a power of 2
+ * isn't big enough. If that happens, chunk splitting will
+ * fail because the free list pointers get overwritten by the
+ * split
+ */
+ ASSERT(sizeof(struct malloc_chunk) < MIN_CHUNK);
if (getenv("MALLOC_DEBUG") != NULL)
debug = 1;
if (getenv("NO_SECRET_MEM") != NULL)