Teach msan that fts_read is safe
fts_read doesn't have msan interceptors yet. msan freaks out when we
use it in AOS. The usage is safe, so teach it that it is safe.
Change-Id: If7e5b6b606ea171351f5097a95ec606e5033dfe6
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/util/file.cc b/aos/util/file.cc
index a11e330..4473d4d 100644
--- a/aos/util/file.cc
+++ b/aos/util/file.cc
@@ -7,6 +7,9 @@
#include <unistd.h>
#include <string_view>
+#if __has_feature(memory_sanitizer)
+#include <sanitizer/msan_interface.h>
+#endif
#include "aos/scoped/scoped_fd.h"
@@ -101,6 +104,15 @@
}
while ((curr = fts_read(ftsp))) {
+#if __has_feature(memory_sanitizer)
+ // fts_read doesn't have propper msan interceptors. Unpoison it ourselves.
+ if (curr) {
+ __msan_unpoison(curr, sizeof(*curr));
+ __msan_unpoison_string(curr->fts_accpath);
+ __msan_unpoison_string(curr->fts_path);
+ __msan_unpoison_string(curr->fts_name);
+ }
+#endif
switch (curr->fts_info) {
case FTS_NS:
case FTS_DNR: