summaryrefslogtreecommitdiff
path: root/openbsd-compat/explicit_bzero.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2017-07-14 14:26:36 +1000
committerDamien Miller <djm@mindrot.org>2017-07-14 14:27:12 +1000
commit738c73dca2c99ee78c531b4cbeefc2008fe438f0 (patch)
tree0189f5a0b6be280538374ecf07665325c322e1f8 /openbsd-compat/explicit_bzero.c
parent8433d51e067e0829f5521c0c646b6fd3fe17e732 (diff)
make explicit_bzero/memset safe for sz=0
Diffstat (limited to 'openbsd-compat/explicit_bzero.c')
-rw-r--r--openbsd-compat/explicit_bzero.c4
1 files changed, 4 insertions, 0 deletions
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 @@
20void 20void
21explicit_bzero(void *p, size_t n) 21explicit_bzero(void *p, size_t n)
22{ 22{
23 if (n == 0)
24 return;
23 (void)memset_s(p, n, 0, n); 25 (void)memset_s(p, n, 0, n);
24} 26}
25 27
@@ -34,6 +36,8 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero;
34void 36void
35explicit_bzero(void *p, size_t n) 37explicit_bzero(void *p, size_t n)
36{ 38{
39 if (n == 0)
40 return;
37 /* 41 /*
38 * clang -fsanitize=memory needs to intercept memset-like functions 42 * clang -fsanitize=memory needs to intercept memset-like functions
39 * to correctly detect memory initialisation. Make sure one is called 43 * to correctly detect memory initialisation. Make sure one is called