Fortify poll and ppoll.
And remove the test for FD_ZERO fortification, which never made much
sense anyway.
Change-Id: Id1009c5298d461fa4722189e8ecaf22f0c529536
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 48764aa..de279b1 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -19,6 +19,7 @@
#include <fcntl.h>
#include <malloc.h>
+#include <poll.h>
#include <signal.h>
#include <stdarg.h>
#include <string.h>
@@ -629,15 +630,6 @@
ASSERT_EXIT(FD_ISSET(0, set), testing::KilledBySignal(SIGABRT), "");
}
-// gtest's ASSERT_EXIT needs a valid expression, but glibc has a do-while macro.
-static void FD_ZERO_function(fd_set* s) { FD_ZERO(s); }
-
-TEST_F(DEATHTEST, FD_ZERO_fortified) {
- char buf[1];
- fd_set* set = (fd_set*) buf;
- ASSERT_EXIT(FD_ZERO_function(set), testing::KilledBySignal(SIGABRT), "");
-}
-
TEST_F(DEATHTEST, read_fortified) {
char buf[1];
size_t ct = atoi("2"); // prevent optimizations
@@ -950,3 +942,15 @@
sprintf(BUF_AND_CONTENTS(buf));
EXPECT_STREQ(CONTENTS, buf);
}
+
+TEST_F(DEATHTEST, poll_fortified) {
+ nfds_t fd_count = atoi("2"); // suppress compiler optimizations
+ pollfd buf[1] = {{0, POLLIN, 0}};
+ ASSERT_EXIT(poll(buf, fd_count, -1), testing::KilledBySignal(SIGABRT), "");
+}
+
+TEST_F(DEATHTEST, ppoll_fortified) {
+ nfds_t fd_count = atoi("2"); // suppress compiler optimizations
+ pollfd buf[1] = {{0, POLLIN, 0}};
+ ASSERT_EXIT(ppoll(buf, fd_count, NULL, NULL), testing::KilledBySignal(SIGABRT), "");
+}