diff options
author | Damien Miller <djm@mindrot.org> | 2017-07-14 14:26:36 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-07-14 14:27:12 +1000 |
commit | 738c73dca2c99ee78c531b4cbeefc2008fe438f0 (patch) | |
tree | 0189f5a0b6be280538374ecf07665325c322e1f8 /openbsd-compat | |
parent | 8433d51e067e0829f5521c0c646b6fd3fe17e732 (diff) |
make explicit_bzero/memset safe for sz=0
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/explicit_bzero.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c index 5078134d..53a00347 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 |