unlinkat \
posix_fallocate \
sendmmsg \
+ explicit_bzero \
])
AC_CHECK_MEMBERS([struct mmsghdr.msg_hdr], [], [], FRR_INCLUDES)
--- /dev/null
+/*
+ * Public domain.
+ * Written by Matthew Dempsky.
+ * Adapted for frr.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#ifndef HAVE_EXPLICIT_BZERO
+#undef explicit_bzero
+
+
+void explicit_bzero(void *buf, size_t len);
+__attribute__((__weak__)) void
+__explicit_bzero_hook(void *buf, size_t len);
+
+__attribute__((__weak__)) void
+__explicit_bzero_hook(void *buf, size_t len)
+{
+}
+
+#if defined(__clang__)
+#pragma clang optimize off
+#else
+#pragma GCC optimize("00")
+#endif
+
+void
+explicit_bzero(void *buf, size_t len)
+{
+ memset(buf, 0, len);
+ __explicit_bzero_hook(buf, len);
+}
+
+#endif
MD5Update(&context, digest, 16); /* then results of 1st
* hash */
MD5Final(digest, &context); /* finish up 2nd pass */
+ explicit_bzero(&context, sizeof(context));
}
state[i] += S[i];
/* Clean the stack. */
- memset(W, 0, 256);
- memset(S, 0, 32);
- memset(&t0, 0, sizeof(t0));
- memset(&t1, 0, sizeof(t0));
+ explicit_bzero(W, 256);
+ explicit_bzero(S, 32);
+ explicit_bzero(&t0, sizeof(t0));
+ explicit_bzero(&t1, sizeof(t0));
}
static unsigned char PAD[64] = {
be32enc_vect(digest, ctx->state, 32);
/* Clear the context state */
- memset((void *)ctx, 0, sizeof(*ctx));
+ explicit_bzero((void *)ctx, sizeof(*ctx));
}
/* Initialize an HMAC-SHA256 operation with the given key. */
SHA256_Update(&ctx->octx, pad, 64);
/* Clean the stack. */
- memset(khash, 0, 32);
+ explicit_bzero(khash, 32);
}
/* Add bytes to the HMAC-SHA256 operation. */
SHA256_Final(digest, &ctx->octx);
/* Clean the stack. */
- memset(ihash, 0, 32);
+ explicit_bzero(ihash, 32);
}
/**
}
/* Clean PShctx, since we never called _Final on it. */
- memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX));
+ explicit_bzero(&PShctx, sizeof(HMAC_SHA256_CTX));
}
#
# libfrr
#
+
lib_LTLIBRARIES += lib/libfrr.la
lib_libfrr_la_LDFLAGS = $(LIB_LDFLAGS) -version-info 0:0:0 -Xlinker -e_libfrr_version
lib_libfrr_la_LIBADD = $(LIBCAP) $(UNWIND_LIBS) $(LIBYANG_LIBS) $(LUA_LIB) $(UST_LIBS) $(LIBCRYPT) $(LIBDL) $(LIBM)
lib/debug.c \
lib/defaults.c \
lib/distribute.c \
+ lib/explicit_bzero.c \
lib/ferr.c \
lib/filter.c \
lib/filter_cli.c \
lib/snmp.c \
# end
+
#
# c-ares support
#
const char *__restrict src, size_t destsize);
#endif
+#ifndef HAVE_EXPLICIT_BZERO
+void explicit_bzero(void *buf, size_t len);
+#endif
+
#if !defined(HAVE_STRUCT_MMSGHDR_MSG_HDR) || !defined(HAVE_SENDMMSG)
/* avoid conflicts in case we have partial support */
#define mmsghdr frr_mmsghdr