From 0006cc3fbf9fdd9f6af88d998ad240a91b0cdcc3 Mon Sep 17 00:00:00 2001 From: Leorize Date: Thu, 14 Dec 2017 07:25:45 +0700 Subject: [PATCH] libs/bsd: add explicit_bzero(3) Signed-off-by: Augustin Cavalier --- headers/compatibility/bsd/string.h | 1 + src/libs/bsd/Jamfile | 1 + src/libs/bsd/explicit_bzero.c | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/libs/bsd/explicit_bzero.c diff --git a/headers/compatibility/bsd/string.h b/headers/compatibility/bsd/string.h index 7d194971d1..c19ea27f87 100644 --- a/headers/compatibility/bsd/string.h +++ b/headers/compatibility/bsd/string.h @@ -17,6 +17,7 @@ extern "C" { #endif char* strsep(char** string, const char* delimiters); +void explicit_bzero(void *buf, size_t len); #ifdef __cplusplus } diff --git a/src/libs/bsd/Jamfile b/src/libs/bsd/Jamfile index 2b77ca4cd3..42f2746789 100644 --- a/src/libs/bsd/Jamfile +++ b/src/libs/bsd/Jamfile @@ -13,6 +13,7 @@ for architectureObject in [ MultiArchSubDirSetup ] { SharedLibrary [ MultiArchDefaultGristFiles libbsd.so ] : daemon.c err.c + explicit_bzero.c fgetln.c getpass.c issetugid.c diff --git a/src/libs/bsd/explicit_bzero.c b/src/libs/bsd/explicit_bzero.c new file mode 100644 index 0000000000..359e4d41bf --- /dev/null +++ b/src/libs/bsd/explicit_bzero.c @@ -0,0 +1,22 @@ +/* $OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */ +/* + * Public domain. + * Written by Matthew Dempsky. + */ + +#include + +__attribute__((weak)) void +__explicit_bzero_hook(void *buf, size_t len); + +__attribute__((weak)) void +__explicit_bzero_hook(void *buf, size_t len) +{ +} + +void +explicit_bzero(void *buf, size_t len) +{ + memset(buf, 0, len); + __explicit_bzero_hook(buf, len); +}