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