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