summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2021-09-19 09:15:23 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2021-09-19 09:15:23 +0000
commit85ea146f0e65b759e1a02db4090305d4af257ca4 (patch)
treecd2cee990c1e0726ae1f7ffbacb45b9e3a049f95
parentdc0f3adf9a102baec66c940195f8ff8174ad586a (diff)
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
-rw-r--r--lib/libc/stdlib/malloc.c6
1 files 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 <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@@ -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)