diff options
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/explicit_bzero.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/openbsd-compat/explicit_bzero.c b/openbsd-compat/explicit_bzero.c index 3c85a4843..5078134d1 100644 --- a/openbsd-compat/explicit_bzero.c +++ b/openbsd-compat/explicit_bzero.c | |||
@@ -7,6 +7,8 @@ | |||
7 | 7 | ||
8 | #include "includes.h" | 8 | #include "includes.h" |
9 | 9 | ||
10 | #include <string.h> | ||
11 | |||
10 | /* | 12 | /* |
11 | * explicit_bzero - don't let the compiler optimize away bzero | 13 | * explicit_bzero - don't let the compiler optimize away bzero |
12 | */ | 14 | */ |
@@ -32,6 +34,17 @@ static void (* volatile ssh_bzero)(void *, size_t) = bzero; | |||
32 | void | 34 | void |
33 | explicit_bzero(void *p, size_t n) | 35 | explicit_bzero(void *p, size_t n) |
34 | { | 36 | { |
37 | /* | ||
38 | * clang -fsanitize=memory needs to intercept memset-like functions | ||
39 | * to correctly detect memory initialisation. Make sure one is called | ||
40 | * directly since our indirection trick above sucessfully confuses it. | ||
41 | */ | ||
42 | #if defined(__has_feature) | ||
43 | # if __has_feature(memory_sanitizer) | ||
44 | memset(p, 0, n); | ||
45 | # endif | ||
46 | #endif | ||
47 | |||
35 | ssh_bzero(p, n); | 48 | ssh_bzero(p, n); |
36 | } | 49 | } |
37 | 50 | ||