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/explicit_bzero.c | |
parent | 8433d51e067e0829f5521c0c646b6fd3fe17e732 (diff) |
make explicit_bzero/memset safe for sz=0
Diffstat (limited to 'openbsd-compat/explicit_bzero.c')
-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 5078134d1..53a003472 100644 --- a/openbsd-compat/explicit_bzero.c +++ b/openbsd-compat/explicit_bzero.c | |||
@@ -20,6 +20,8 @@ | |||
20 | void | 20 | void |
21 | explicit_bzero(void *p, size_t n) | 21 | explicit_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; | |||
34 | void | 36 | void |
35 | explicit_bzero(void *p, size_t n) | 37 | explicit_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 |