Skip to content

Commit

Permalink
Disable statfs64 sanitizer wrappers on Macs. The system calls do not …
Browse files Browse the repository at this point in the history
…exist

in 64-bit only operating systems and there is no obvious way to distinguish
at compile time the environments that do or do not offer statfs64.
  • Loading branch information
VoxSciurorum authored and neboat committed Mar 5, 2021
1 parent 21c13db commit 8435006
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ POST_SYSCALL(statfs)(long res, const void *path, void *buf) {
}
}

#if !SANITIZER_MAC
PRE_SYSCALL(statfs64)(const void *path, long sz, void *buf) {
if (path)
PRE_READ(path, __sanitizer::internal_strlen((const char *)path) + 1);
Expand All @@ -852,6 +853,7 @@ POST_SYSCALL(statfs64)(long res, const void *path, long sz, void *buf) {
if (buf) POST_WRITE(buf, struct_statfs64_sz);
}
}
#endif

PRE_SYSCALL(fstatfs)(long fd, void *buf) {}

Expand All @@ -861,13 +863,15 @@ POST_SYSCALL(fstatfs)(long res, long fd, void *buf) {
}
}

#if !SANITIZER_MAC
PRE_SYSCALL(fstatfs64)(long fd, long sz, void *buf) {}

POST_SYSCALL(fstatfs64)(long res, long fd, long sz, void *buf) {
if (res >= 0) {
if (buf) POST_WRITE(buf, struct_statfs64_sz);
}
}
#endif
#endif // !SANITIZER_ANDROID

PRE_SYSCALL(lstat)(const void *filename, void *statbuf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
#define SANITIZER_INTERCEPT_STATFS \
(SI_FREEBSD || SI_MAC || SI_LINUX_NOT_ANDROID || SI_SOLARIS)
#define SANITIZER_INTERCEPT_STATFS64 \
((SI_MAC && !SI_IOS) || SI_LINUX_NOT_ANDROID)
(SI_LINUX_NOT_ANDROID)
#define SANITIZER_INTERCEPT_STATVFS \
(SI_FREEBSD || SI_NETBSD || SI_OPENBSD || SI_LINUX_NOT_ANDROID)
#define SANITIZER_INTERCEPT_STATVFS64 SI_LINUX_NOT_ANDROID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ typedef struct user_fpregs elf_fpregset_t;
namespace __sanitizer {
unsigned struct_utsname_sz = sizeof(struct utsname);
unsigned struct_stat_sz = sizeof(struct stat);
#if !SANITIZER_IOS
#if !SANITIZER_MAC
unsigned struct_stat64_sz = sizeof(struct stat64);
#endif // !SANITIZER_IOS
#endif // !SANITIZER_MAC
unsigned struct_rusage_sz = sizeof(struct rusage);
unsigned struct_tm_sz = sizeof(struct tm);
unsigned struct_passwd_sz = sizeof(struct passwd);
Expand All @@ -196,10 +196,6 @@ namespace __sanitizer {
unsigned struct_regex_sz = sizeof(regex_t);
unsigned struct_regmatch_sz = sizeof(regmatch_t);

#if SANITIZER_MAC && !SANITIZER_IOS
unsigned struct_statfs64_sz = sizeof(struct statfs64);
#endif // SANITIZER_MAC && !SANITIZER_IOS

#if !SANITIZER_ANDROID
unsigned struct_fstab_sz = sizeof(struct fstab);
unsigned struct_statfs_sz = sizeof(struct statfs);
Expand Down

0 comments on commit 8435006

Please sign in to comment.