diff options
author | 2019-05-23 06:52:13 +0000 | |
---|---|---|
committer | 2019-05-23 06:52:13 +0000 | |
commit | b0f539e9923c93d213bbde92bfd6b7a67cb6927c (patch) | |
tree | 0b6aa96acd6607de5d6163d94572725929b020b7 /regress/lib/libc/malloc/malloc_general/malloc_general.c | |
parent | Inline 18 bytes of packet header so we can send vlan tagged packets. (diff) | |
download | wireguard-openbsd-b0f539e9923c93d213bbde92bfd6b7a67cb6927c.tar.xz wireguard-openbsd-b0f539e9923c93d213bbde92bfd6b7a67cb6927c.zip |
Throw malloc_conceal and freezero into the mix.
Diffstat (limited to 'regress/lib/libc/malloc/malloc_general/malloc_general.c')
-rw-r--r-- | regress/lib/libc/malloc/malloc_general/malloc_general.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/regress/lib/libc/malloc/malloc_general/malloc_general.c b/regress/lib/libc/malloc/malloc_general/malloc_general.c index b90e97ad15d..8abc5210ca7 100644 --- a/regress/lib/libc/malloc/malloc_general/malloc_general.c +++ b/regress/lib/libc/malloc/malloc_general/malloc_general.c @@ -57,7 +57,7 @@ check(u_char *p, size_t sz) int main(int argc, char *argv[]) { - int count, p, i; + int count, p, r, i; void * q; size_t sz; char mo[20]; @@ -92,7 +92,8 @@ main(int argc, char *argv[]) #ifdef VERBOSE printf("M %zu=", sz); #endif - a[i].p = malloc(sz); + r = arc4random_uniform(2); + a[i].p = r == 0 ? malloc_conceal(sz) : malloc(sz); a[i].sz = sz; #ifdef VERBOSE printf("%p\n", a[i].p); @@ -122,7 +123,11 @@ main(int argc, char *argv[]) for (i = 0; i < N; i++) { if (a[i].p) check(a[i].p, a[i].sz); - free(a[i].p); + r = arc4random_uniform(2); + if (r) + free(a[i].p); + else + freezero(a[i].p, a[i].sz); } printf("\n"); return 0; |