aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Holstein <nathan.holstein@gmail.com>2015-08-03 18:28:22 -0400
committerNathan Holstein <nathan.holstein@gmail.com>2015-08-05 08:58:17 -0400
commitfed10b5bab6e9f6b3a06a7b3553dafa6157dce9c (patch)
treeeb3d4bb15f97e365e8b30be119ced6c732fbed56
parent815f1670961bee0f8104f87feae89835249d51a6 (diff)
downloadopendoas-fed10b5bab6e9f6b3a06a7b3553dafa6157dce9c.tar.gz
Import explicit_bzero() from OpenBSD.
-rw-r--r--Makefile2
-rw-r--r--libopenbsd/explicit_bzero.c21
-rw-r--r--libopenbsd/openbsd.h3
3 files changed, 25 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 7ccacea..0b9112e 100644
--- 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
index 0000000..9a646c6
--- /dev/null
+++ b/libopenbsd/explicit_bzero.c
@@ -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);
+}
diff --git a/libopenbsd/openbsd.h b/libopenbsd/openbsd.h
index 5f7c364..1fa73af 100644
--- a/libopenbsd/openbsd.h
+++ b/libopenbsd/openbsd.h
@@ -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);