diff options
author | Elliott Hughes <enh@google.com> | 2015-02-02 09:15:19 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-02-02 09:15:19 -0800 |
commit | 4674e3899afcc6b3ac8a48cdb716695d5489d26b (patch) | |
tree | b4dadb078646cbb46dd62a14c623b7e0d06619e3 /tests/fortify_test.cpp | |
parent | ffbda83b302e3c3970135013d2bb92402e040fe5 (diff) | |
download | android_bionic-4674e3899afcc6b3ac8a48cdb716695d5489d26b.tar.gz android_bionic-4674e3899afcc6b3ac8a48cdb716695d5489d26b.tar.bz2 android_bionic-4674e3899afcc6b3ac8a48cdb716695d5489d26b.zip |
Fortify poll and ppoll.
And remove the test for FD_ZERO fortification, which never made much
sense anyway.
Change-Id: Id1009c5298d461fa4722189e8ecaf22f0c529536
Diffstat (limited to 'tests/fortify_test.cpp')
-rw-r--r-- | tests/fortify_test.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp index 48764aa9f..de279b1a2 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 @@ TEST_F(DEATHTEST, FD_ISSET_2_fortified) { 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 @@ TEST(TEST_NAME, s_n_printf_macro_expansion) { 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), ""); +} |