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