From 5576bc40c43cc6479ec8d4fccc16927073e664fb Mon Sep 17 00:00:00 2001 From: tb Date: Sun, 19 Sep 2021 09:15:22 +0000 Subject: [PATCH] Switch two calls from memset() to explicit_bzero() This matches the documented behavior more obviously and ensures that these aren't optimized away, although this is unlikely. Discussed with deraadt and otto --- lib/libc/stdlib/malloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 618554d293e..64273b49fe4 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.271 2021/07/23 18:04:28 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.272 2021/09/19 09:15:22 tb Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -741,7 +741,7 @@ unmap(struct dir_info *d, void *p, size_t sz, size_t clear) /* fill slot */ if (clear > 0) - memset(p, 0, clear); + explicit_bzero(p, clear); if (mopts.malloc_freeunmap) mprotect(p, sz, PROT_NONE); else @@ -1432,7 +1432,7 @@ ofree(struct dir_info **argpool, void *p, int clear, int check, size_t argsz) } } else if (argsz > 0) { r = find(pool, p); - memset(p, 0, argsz); + explicit_bzero(p, argsz); } if (p != NULL) { if (r == NULL) -- 2.20.1