]> git.armaanb.net Git - opendoas.git/commitdiff
Import explicit_bzero() from OpenBSD.
authorNathan Holstein <nathan.holstein@gmail.com>
Mon, 3 Aug 2015 22:28:22 +0000 (18:28 -0400)
committerNathan Holstein <nathan.holstein@gmail.com>
Wed, 5 Aug 2015 12:58:17 +0000 (08:58 -0400)
Makefile
libopenbsd/explicit_bzero.c [new file with mode: 0644]
libopenbsd/openbsd.h

index 7ccacea78c998e650ffdcbb54c93ab69dcfa6322..0b9112e6c63d4d168f56165174501086515b6013 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ MANDIR?=/usr/share/man
 default: ${PROG}
 
 OPENBSD:=reallocarray.c strtonum.c execvpe.c setresuid.c \
-       auth_userokay.c setusercontext.c
+       auth_userokay.c setusercontext.c explicit_bzero.c
 OPENBSD:=$(addprefix libopenbsd/,${OPENBSD:.c=.o})
 libopenbsd.a: ${OPENBSD}
        ${AR} -r $@ $?
diff --git a/libopenbsd/explicit_bzero.c b/libopenbsd/explicit_bzero.c
new file mode 100644 (file)
index 0000000..9a646c6
--- /dev/null
@@ -0,0 +1,21 @@
+/*     $OpenBSD: explicit_bzero.c,v 1.2 2014/06/10 04:17:37 deraadt Exp $ */
+/*
+ * Public domain.
+ * Written by Matthew Dempsky.
+ */
+
+#include <string.h>
+
+#define __UNUSED __attribute__ ((unused))
+
+__attribute__((weak)) void
+__explicit_bzero_hook(__UNUSED void *buf, __UNUSED size_t len)
+{
+}
+
+void
+explicit_bzero(void *buf, size_t len)
+{
+       memset(buf, 0, len);
+       __explicit_bzero_hook(buf, len);
+}
index 5f7c364c2a0809baa922a206012ea2e87b4979d9..1fa73afcd95d002379268ae4991fed08f76824bb 100644 (file)
@@ -31,6 +31,9 @@ void * reallocarray(void *optr, size_t nmemb, size_t size);
 long long strtonum(const char *numstr, long long minval,
                long long maxval, const char **errstrp);
 
+/* string.h */
+void explicit_bzero(void *, size_t);
+
 /* unistd.h */
 int execvpe(const char *, char *const *, char *const *);
 int setresuid(uid_t, uid_t, uid_t);