xref: /freebsd/contrib/unbound/compat/explicit_bzero.c (revision fcb560670601b2a4d87bb31d7531c8dcc37ee71b)
1 /*	$OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */
2 /*
3  * Public domain.
4  * Written by Matthew Dempsky.
5  */
6 #include "config.h"
7 #include <string.h>
8 
9 __attribute__((weak)) void
10 __explicit_bzero_hook(void *ATTR_UNUSED(buf), size_t ATTR_UNUSED(len))
11 {
12 }
13 
14 void
15 explicit_bzero(void *buf, size_t len)
16 {
17 #ifdef UB_ON_WINDOWS
18 	SecureZeroMemory(buf, len);
19 #endif
20 	memset(buf, 0, len);
21 	__explicit_bzero_hook(buf, len);
22 }
23