diff options
author | delphij <delphij@FreeBSD.org> | 2009-03-28 04:00:46 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2009-03-28 04:00:46 +0000 |
commit | 38e77f44827a3da21018f0a385572fd4c08d9a45 (patch) | |
tree | 79143c20fc600108f05874a7856ca9b3575262a2 /lib/libc/db/mpool/mpool.c | |
parent | 2f83429b40ea5e9d7042360ddd01d674a50b4306 (diff) | |
download | FreeBSD-src-38e77f44827a3da21018f0a385572fd4c08d9a45.zip FreeBSD-src-38e77f44827a3da21018f0a385572fd4c08d9a45.tar.gz |
When allocating memory, zero out them if we don't intend to overwrite them
all; before freeing memory, zero out them before we release it as free
heap. This will eliminate some potential information leak issue.
While there, remove the PURIFY option. There is a slight difference between
the new behavior and the old -DPURIFY behavior, with the latter initializes
memory with 0xff's. The difference between old and new approach does not
generate observable difference.
Obtained from: OpenBSD (partly).
Diffstat (limited to 'lib/libc/db/mpool/mpool.c')
-rw-r--r-- | lib/libc/db/mpool/mpool.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index 779ac89..5610eb5 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -332,14 +332,11 @@ mpool_bkt(MPOOL *mp) return (bp); } -new: if ((bp = (BKT *)malloc(sizeof(BKT) + mp->pagesize)) == NULL) +new: if ((bp = (BKT *)calloc(1, sizeof(BKT) + mp->pagesize)) == NULL) return (NULL); #ifdef STATISTICS ++mp->pagealloc; #endif -#if defined(DEBUG) || defined(PURIFY) - memset(bp, 0xff, sizeof(BKT) + mp->pagesize); -#endif bp->page = (char *)bp + sizeof(BKT); ++mp->curcache; return (bp); |