diff options
author | tb <> | 2021-09-19 09:15:22 +0000 |
---|---|---|
committer | tb <> | 2021-09-19 09:15:22 +0000 |
commit | 88a8d6683055f73a054da9693c5a730d3201b0cb (patch) | |
tree | a4125d718ef8d8b4729cda9c4f3971e37e71254c | |
parent | bf6954f460bcb5d9745901e52a0ced497aed3f4d (diff) | |
download | openbsd-88a8d6683055f73a054da9693c5a730d3201b0cb.tar.gz openbsd-88a8d6683055f73a054da9693c5a730d3201b0cb.tar.bz2 openbsd-88a8d6683055f73a054da9693c5a730d3201b0cb.zip |
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-- | src/lib/libc/stdlib/malloc.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 618554d293..64273b49fe 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: malloc.c,v 1.271 2021/07/23 18:04:28 otto Exp $ */ | 1 | /* $OpenBSD: malloc.c,v 1.272 2021/09/19 09:15:22 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> | 3 | * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> |
4 | * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> | 4 | * 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) | |||
741 | 741 | ||
742 | /* fill slot */ | 742 | /* fill slot */ |
743 | if (clear > 0) | 743 | if (clear > 0) |
744 | memset(p, 0, clear); | 744 | explicit_bzero(p, clear); |
745 | if (mopts.malloc_freeunmap) | 745 | if (mopts.malloc_freeunmap) |
746 | mprotect(p, sz, PROT_NONE); | 746 | mprotect(p, sz, PROT_NONE); |
747 | else | 747 | else |
@@ -1432,7 +1432,7 @@ ofree(struct dir_info **argpool, void *p, int clear, int check, size_t argsz) | |||
1432 | } | 1432 | } |
1433 | } else if (argsz > 0) { | 1433 | } else if (argsz > 0) { |
1434 | r = find(pool, p); | 1434 | r = find(pool, p); |
1435 | memset(p, 0, argsz); | 1435 | explicit_bzero(p, argsz); |
1436 | } | 1436 | } |
1437 | if (p != NULL) { | 1437 | if (p != NULL) { |
1438 | if (r == NULL) | 1438 | if (r == NULL) |