summaryrefslogtreecommitdiff
path: root/src/string
diff options
context:
space:
mode:
authorDavid Carlier <dcarlier@afilias.info>2018-06-15 13:30:09 +0000
committerRich Felker <dalias@aerifal.cx>2018-06-26 16:59:12 -0400
commit05ac345f895098657cf44d419b5d572161ebaf43 (patch)
tree03edd3b56ada466c2aa5baf5ec33972cc2a322d2 /src/string
parent5c8e69267b9ae919e55eee4b79580224111bc3ba (diff)
downloadmusl-05ac345f895098657cf44d419b5d572161ebaf43.tar.gz
add explicit_bzero implementation
maintainer's note: past sentiment was that, despite being imperfect and unable to force clearing of all possible copies of sensitive data (e.g. in registers, register spills, signal contexts left on the stack, etc.) this function would be added if major implementations agreed on it, which has happened -- several BSDs and glibc all include it.
Diffstat (limited to 'src/string')
-rw-r--r--src/string/explicit_bzero.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/string/explicit_bzero.c b/src/string/explicit_bzero.c
new file mode 100644
index 00000000..3d270040
--- /dev/null
+++ b/src/string/explicit_bzero.c
@@ -0,0 +1,8 @@
+#define _BSD_SOURCE
+#include <string.h>
+
+void explicit_bzero(void *d, size_t n)
+{
+ memset(d, 0, n);
+ __asm__ __volatile__ ("" : : "r"(d) : "memory");
+}