diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-04-18 15:17:33 -0700 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-04-18 15:17:33 -0700 |
commit | 1a22178a4dea836dac7403cee3f74375dd2c9bbd (patch) | |
tree | 89c777c6e1f58e829658c069a20f46956ad78745 | |
parent | 614406260e86408fb42edc2cea1a7bb5cac20906 (diff) | |
download | secret-memory-preloader-1a22178a4dea836dac7403cee3f74375dd2c9bbd.tar.gz |
Add check for chunk minsize
-rw-r--r-- | preload.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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) |