opendoas

A portable version of the OpenBSD `doas` command
git clone https://pi.duncano.de/git/opendoas.git
Log | Files | Refs | README | LICENSE

commit fed10b5bab6e9f6b3a06a7b3553dafa6157dce9c
parent 815f1670961bee0f8104f87feae89835249d51a6
Author: Nathan Holstein <nathan.holstein@gmail.com>
Date:   Mon,  3 Aug 2015 18:28:22 -0400

Import explicit_bzero() from OpenBSD.

Diffstat:
Makefile | 2+-
libopenbsd/explicit_bzero.c | 21+++++++++++++++++++++
libopenbsd/openbsd.h | 3+++
3 files changed, 25 insertions(+), 1 deletion(-)

diff --git 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 @@ -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 @@ -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);