diff options
| author | tb <> | 2021-09-19 09:15:22 +0000 | 
|---|---|---|
| committer | tb <> | 2021-09-19 09:15:22 +0000 | 
| commit | f7454b8bede1be416adc77267c65bdcb40ee9f98 (patch) | |
| tree | a4125d718ef8d8b4729cda9c4f3971e37e71254c /src/lib/libc/stdlib/malloc.c | |
| parent | 1377a15fedcd957ed14732db959a3c76892b80a6 (diff) | |
| download | openbsd-f7454b8bede1be416adc77267c65bdcb40ee9f98.tar.gz openbsd-f7454b8bede1be416adc77267c65bdcb40ee9f98.tar.bz2 openbsd-f7454b8bede1be416adc77267c65bdcb40ee9f98.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
Diffstat (limited to 'src/lib/libc/stdlib/malloc.c')
| -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) | 
