1*5e3eaea3SApple OSS Distributions #include <darwintest.h> 2*5e3eaea3SApple OSS Distributions #include <darwintest_utils.h> 3*5e3eaea3SApple OSS Distributions #include <crt_externs.h> 4*5e3eaea3SApple OSS Distributions #include <sys/types.h> 5*5e3eaea3SApple OSS Distributions #include <sys/uio.h> 6*5e3eaea3SApple OSS Distributions #include <unistd.h> 7*5e3eaea3SApple OSS Distributions #include <fcntl.h> 8*5e3eaea3SApple OSS Distributions 9*5e3eaea3SApple OSS Distributions T_GLOBAL_META( 10*5e3eaea3SApple OSS Distributions T_META_NAMESPACE("xnu.fd"), 11*5e3eaea3SApple OSS Distributions T_META_RUN_CONCURRENTLY(true)); 12*5e3eaea3SApple OSS Distributions 13*5e3eaea3SApple OSS Distributions T_DECL(fd_invalid_pread, "Test for 66711697: make sure we get EFAULT") 14*5e3eaea3SApple OSS Distributions { 15*5e3eaea3SApple OSS Distributions int fd; 16*5e3eaea3SApple OSS Distributions ssize_t rc; 17*5e3eaea3SApple OSS Distributions 18*5e3eaea3SApple OSS Distributions fd = open(*_NSGetProgname(), O_RDONLY); 19*5e3eaea3SApple OSS Distributions T_ASSERT_POSIX_SUCCESS(fd, "open(self)"); 20*5e3eaea3SApple OSS Distributions 21*5e3eaea3SApple OSS Distributions rc = pread(fd, (void *)~0, 64 << 10, 0); 22*5e3eaea3SApple OSS Distributions T_ASSERT_POSIX_FAILURE(rc, EFAULT, "pread should fail with EFAULT"); 23*5e3eaea3SApple OSS Distributions 24*5e3eaea3SApple OSS Distributions close(fd); 25*5e3eaea3SApple OSS Distributions } 26