make explicit_bzero/memset safe for sz=0

This commit is contained in:
Damien Miller 2017-07-14 14:26:36 +10:00
parent 8433d51e06
commit 738c73dca2
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,8 @@
void void
explicit_bzero(void *p, size_t n) explicit_bzero(void *p, size_t n)
{ {
if (n == 0)
return;
(void)memset_s(p, n, 0, n); (void)memset_s(p, n, 0, n);
} }
@ -34,6 +36,8 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero;
void void
explicit_bzero(void *p, size_t n) explicit_bzero(void *p, size_t n)
{ {
if (n == 0)
return;
/* /*
* clang -fsanitize=memory needs to intercept memset-like functions * clang -fsanitize=memory needs to intercept memset-like functions
* to correctly detect memory initialisation. Make sure one is called * to correctly detect memory initialisation. Make sure one is called