[Sanitizer] getmntinfo support in FreeBSD

Reviewers: krytarowski

Reviewed By: krytarowski

Differential Revision: https://reviews.llvm.org/D55354

llvm-svn: 348500
This commit is contained in:
David Carlier 2018-12-06 17:04:18 +00:00
parent 579264bd59
commit 51e820d0d8
3 changed files with 15 additions and 1 deletions

View File

@ -7278,7 +7278,11 @@ INTERCEPTOR(int, getmntinfo, void **mntbufp, int flags) {
if (cnt > 0 && mntbufp) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, mntbufp, sizeof(void *));
if (*mntbufp)
#if SANITIZER_NETBSD
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *mntbufp, cnt * struct_statvfs_sz);
#else
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, *mntbufp, cnt * struct_statfs_sz);
#endif
}
return cnt;
}

View File

@ -518,7 +518,7 @@
#define SANITIZER_INTERCEPT_NETENT SI_NETBSD
#define SANITIZER_INTERCEPT_SETVBUF (SI_NETBSD || SI_FREEBSD || \
SI_LINUX || SI_MAC)
#define SANITIZER_INTERCEPT_GETMNTINFO SI_NETBSD
#define SANITIZER_INTERCEPT_GETMNTINFO (SI_NETBSD || SI_FREEBSD)
#define SANITIZER_INTERCEPT_MI_VECTOR_HASH SI_NETBSD
#define SANITIZER_INTERCEPT_GETVFSSTAT SI_NETBSD
#define SANITIZER_INTERCEPT_REGEX SI_NETBSD

View File

@ -1,8 +1,14 @@
// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s
//
// UNSUPPORTED: linux, darwin, solaris
#include <sys/types.h>
#if defined(__NetBSD__)
#include <sys/statvfs.h>
#else
#include <sys/mount.h>
#endif
#include <err.h>
#include <stdio.h>
@ -11,7 +17,11 @@
int main(void) {
printf("getmntinfo\n");
#if defined(__NetBSD__)
struct statvfs *fss;
#else
struct statfs *fss;
#endif
int nfss = getmntinfo(&fss, MNT_NOWAIT);
if (nfss <= 0)
errx(1, "getmntinfo");