From 60f45665dbe72537ce6f48b53929b9efcad273bb Mon Sep 17 00:00:00 2001
From: Leorize <alaviss@users.noreply.github.com>
Date: Thu, 14 Dec 2017 07:25:45 +0700
Subject: [PATCH 3/5] libs/bsd: add explicit_bzero(3)
---
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 7d194971..c19ea27f 100644
a
|
b
|
extern "C" {
|
17 | 17 | #endif |
18 | 18 | |
19 | 19 | char* strsep(char** string, const char* delimiters); |
| 20 | void explicit_bzero(void *buf, size_t len); |
20 | 21 | |
21 | 22 | #ifdef __cplusplus |
22 | 23 | } |
diff --git a/src/libs/bsd/Jamfile b/src/libs/bsd/Jamfile
index 2b77ca4c..42f27467 100644
a
|
b
|
for architectureObject in [ MultiArchSubDirSetup ] {
|
13 | 13 | SharedLibrary [ MultiArchDefaultGristFiles libbsd.so ] : |
14 | 14 | daemon.c |
15 | 15 | err.c |
| 16 | explicit_bzero.c |
16 | 17 | fgetln.c |
17 | 18 | getpass.c |
18 | 19 | issetugid.c |
diff --git a/src/libs/bsd/explicit_bzero.c b/src/libs/bsd/explicit_bzero.c
new file mode 100644
index 00000000..359e4d41
-
|
+
|
|
| 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 | |
| 7 | #include <string.h> |
| 8 | |
| 9 | __attribute__((weak)) void |
| 10 | __explicit_bzero_hook(void *buf, size_t len); |
| 11 | |
| 12 | __attribute__((weak)) void |
| 13 | __explicit_bzero_hook(void *buf, size_t len) |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | void |
| 18 | explicit_bzero(void *buf, size_t len) |
| 19 | { |
| 20 | memset(buf, 0, len); |
| 21 | __explicit_bzero_hook(buf, len); |
| 22 | } |