From 738c73dca2c99ee78c531b4cbeefc2008fe438f0 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Fri, 14 Jul 2017 14:26:36 +1000 Subject: [PATCH] make explicit_bzero/memset safe for sz=0 --- openbsd-compat/explicit_bzero.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c index 5078134d1..53a003472 100644 --- a/openbsd-compat/explicit_bzero.c +++ b/openbsd-compat/explicit_bzero.c @@ -20,6 +20,8 @@ void explicit_bzero(void *p, size_t n) { + if (n == 0) + return; (void)memset_s(p, n, 0, n); } @@ -34,6 +36,8 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero; void explicit_bzero(void *p, size_t n) { + if (n == 0) + return; /* * clang -fsanitize=memory needs to intercept memset-like functions * to correctly detect memory initialisation. Make sure one is called