From: Nathan Holstein Date: Mon, 3 Aug 2015 22:28:22 +0000 (-0400) Subject: Import explicit_bzero() from OpenBSD. X-Git-Tag: v0.1~36 X-Git-Url: https://git.armaanb.net/?p=opendoas.git;a=commitdiff_plain;h=fed10b5bab6e9f6b3a06a7b3553dafa6157dce9c Import explicit_bzero() from OpenBSD. --- 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 + +#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);