From 52918795ad2c646d70d93106798724e0d6e1fac2 Mon Sep 17 00:00:00 2001 From: otto Date: Mon, 19 Apr 2021 06:43:15 +0000 Subject: [PATCH] Same internal consistency check as libc malloc: size in hash table should correspond to size of chunk meta data --- libexec/ld.so/malloc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libexec/ld.so/malloc.c b/libexec/ld.so/malloc.c index 3dba1283fd2..c5eae02e8f6 100644 --- a/libexec/ld.so/malloc.c +++ b/libexec/ld.so/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.31 2020/12/26 13:17:33 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.32 2021/04/19 06:43:15 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -950,7 +950,10 @@ ofree(void *p) } else { void *tmp; int i; + struct chunk_info *info = (struct chunk_info *)r->size; + if (info->size != sz) + wrterror("internal struct corrupt"); find_chunknum(g_pool, r, p, CHUNK_CANARIES); for (i = 0; i <= MALLOC_DELAYED_CHUNK_MASK; i++) { if (p == g_pool->delayed_chunks[i]) -- 2.20.1