Fortify ppoll64.
I've deliberately not bothered with the GCC implementation because we'll
have removed GCC from the NDK before anyone gets to use this.
Bug: http://b/72493232
Test: ran tests
Change-Id: Icfc2a3b214739ab53aa41bacacc11b5c67498fb4
diff --git a/tests/fortify_filecheck_diagnostics_test.cpp b/tests/fortify_filecheck_diagnostics_test.cpp
index c6198c6..375a156 100644
--- a/tests/fortify_filecheck_diagnostics_test.cpp
+++ b/tests/fortify_filecheck_diagnostics_test.cpp
@@ -278,7 +278,15 @@
// NOLINTNEXTLINE(whitespace/line_length)
// GCC: error: call to '__ppoll_too_small_error' declared with attribute error: ppoll: pollfd array smaller than fd count
// CLANG: error: in call to 'ppoll', fd_count is larger than the given buffer
- ppoll(fds, 2, &timeout, NULL);
+ ppoll(fds, 2, &timeout, nullptr);
+}
+
+void test_ppoll64() {
+ pollfd fds[1];
+ timespec timeout;
+ // NOLINTNEXTLINE(whitespace/line_length)
+ // CLANG: error: in call to 'ppoll64', fd_count is larger than the given buffer
+ ppoll64(fds, 2, &timeout, nullptr);
}
void test_fread_overflow() {
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 67c124d..b5b858f 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -995,7 +995,18 @@
// Set timeout to zero to prevent waiting in ppoll when fortify test fails.
timespec timeout;
timeout.tv_sec = timeout.tv_nsec = 0;
- ASSERT_FORTIFY(ppoll(buf, fd_count, &timeout, NULL));
+ ASSERT_FORTIFY(ppoll(buf, fd_count, &timeout, nullptr));
+}
+
+TEST_F(DEATHTEST, ppoll64_fortified) {
+#if __BIONIC__ // glibc doesn't have ppoll64.
+ nfds_t fd_count = atoi("2"); // suppress compiler optimizations
+ pollfd buf[1] = {{0, POLLIN, 0}};
+ // Set timeout to zero to prevent waiting in ppoll when fortify test fails.
+ timespec timeout;
+ timeout.tv_sec = timeout.tv_nsec = 0;
+ ASSERT_FORTIFY(ppoll64(buf, fd_count, &timeout, nullptr));
+#endif
}
TEST_F(DEATHTEST, open_O_CREAT_without_mode_fortified) {