From: Damien Miller Date: Fri, 14 Jul 2017 04:26:36 +0000 (+1000) Subject: make explicit_bzero/memset safe for sz=0 X-Git-Tag: V_7_6_P1~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=738c73dca2c99ee78c531b4cbeefc2008fe438f0;p=thirdparty%2Fopenssh-portable.git make explicit_bzero/memset safe for sz=0 --- 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