summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej@ahunt.org>2021-06-04 18:25:19 +0200
committerEdward Thomson <ethomson@edwardthomson.com>2022-07-12 14:27:46 -0400
commit39ba0ee6045a68e657e074d8290b4b77baae72c0 (patch)
tree7c579ccd17fcbd6c2e6d1f6339582a81a9488288 /deps
parent6febb7d7670cc1f2b112c1f1540cd872cb208f37 (diff)
downloadlibgit2-39ba0ee6045a68e657e074d8290b4b77baae72c0.tar.gz
zlib: slide_hash: add MSAN annotation to suppress known read from uninitialised memory
slide_hash knowingly reads (possibly) uninitialised memory, see comment lower down about prev[n] potentially being garbage. In this case, the result is never used - so we don't care about MSAN complaining about this read. By adding the no_sanitize("memory") attribute, clients of zlib won't see this (unnecessary) error when building and running with MemorySanitizer. An alternative approach is for clients to build zlib with -fsanitize-ignorelist=... where the ignorelist contains something like 'fun:slide_hash'. But that's more work and needs to be redone for any and all CI systems running a given project with MSAN. Adding this annotation to zlib's sources is overall more convenient - but also won't affect non-MSAN builds. This specific issue was found while running git's test suite, but has also been reported by other clients, see e.g. #518.
Diffstat (limited to 'deps')
-rw-r--r--deps/zlib/deflate.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/deps/zlib/deflate.c b/deps/zlib/deflate.c
index 799fb93cc..feacd7832 100644
--- a/deps/zlib/deflate.c
+++ b/deps/zlib/deflate.c
@@ -201,6 +201,11 @@ local const config configuration_table[10] = {
* bit values at the expense of memory usage). We slide even when level == 0 to
* keep the hash table consistent if we switch back to level > 0 later.
*/
+#if defined(__has_feature)
+# if __has_feature(memory_sanitizer)
+__attribute__((no_sanitize("memory")))
+# endif
+#endif
local void slide_hash(s)
deflate_state *s;
{