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