]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: memory: also poison the area on freeing
authorWilly Tarreau <w@1wt.eu>
Fri, 15 Nov 2019 05:59:54 +0000 (06:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 15 Nov 2019 06:06:46 +0000 (07:06 +0100)
Doing so sometimes helps detect some UAF situations without the overhead
associated to the DEBUG_UAF define.

include/common/memory.h

index ae1ad22977ac766b514b5ccd30e377d29e5a8aef..1aab6d460bd6538d43535be1c9ba0e6e7df3aa59 100644 (file)
@@ -332,6 +332,8 @@ static inline void pool_free(struct pool_head *pool, void *ptr)
                if (*POOL_LINK(pool, ptr) != (void *)pool)
                        *(volatile int *)0 = 0;
 #endif
+               if (mem_poison_byte >= 0)
+                       memset(ptr, mem_poison_byte, pool->size);
                pool_put_to_cache(pool, ptr);
        }
 }