summaryrefslogtreecommitdiffstats
path: root/src/stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stat.c')
-rw-r--r--src/stat.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/stat.c b/src/stat.c
index 590a1d6..3f70e6c 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -5,6 +5,7 @@
#include "bfstd.h"
#include "config.h"
#include "diag.h"
+#include "sanity.h"
#include <errno.h>
#include <fcntl.h>
#include <string.h>
@@ -132,17 +133,18 @@ static int bfs_stat_impl(int at_fd, const char *at_path, int at_flags, struct bf
* Wrapper for the statx() system call, which had no glibc wrapper prior to 2.28.
*/
static int bfs_statx(int at_fd, const char *at_path, int at_flags, unsigned int mask, struct statx *buf) {
-#if __has_feature(memory_sanitizer)
- // -fsanitize=memory doesn't know about statx(), so tell it the memory
- // got initialized
- memset(buf, 0, sizeof(*buf));
-#endif
-
#if BFS_LIBC_STATX
- return statx(at_fd, at_path, at_flags, mask, buf);
+ int ret = statx(at_fd, at_path, at_flags, mask, buf);
#else
- return syscall(SYS_statx, at_fd, at_path, at_flags, mask, buf);
+ int ret = syscall(SYS_statx, at_fd, at_path, at_flags, mask, buf);
#endif
+
+ if (ret == 0) {
+ // -fsanitize=memory doesn't know about statx()
+ sanitize_init(buf);
+ }
+
+ return ret;
}
/**