diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-05-25 14:19:21 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-05-25 14:30:05 -0400 |
commit | 24a67ef8265e5873c0967ded296a9e57ed9f2914 (patch) | |
tree | ab48ef165aa5f83465b99354794787914f4dd9a9 /src/stat.c | |
parent | eef75524aec3910097cb6923c30b898ad98179fe (diff) | |
download | bfs-24a67ef8265e5873c0967ded296a9e57ed9f2914.tar.xz |
sanity: Add wrappers for sanitizer interfaces
Diffstat (limited to 'src/stat.c')
-rw-r--r-- | src/stat.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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; } /** |