aboutsummaryrefslogtreecommitdiffstats
path: root/tests/fortify_test.cpp
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2014-10-06 00:39:47 +0000
committerNick Kralevich <nnk@google.com>2014-10-06 00:39:47 +0000
commit884a3de60f442748a1d15c6a219f7058e03e38e2 (patch)
tree5c562cf12fcb46b262782fc0893d26c13366dafa /tests/fortify_test.cpp
parent9b543ffeac216189cc8125f7624da9a8cbcbe2e4 (diff)
downloadandroid_bionic-884a3de60f442748a1d15c6a219f7058e03e38e2.tar.gz
android_bionic-884a3de60f442748a1d15c6a219f7058e03e38e2.tar.bz2
android_bionic-884a3de60f442748a1d15c6a219f7058e03e38e2.zip
Revert "cdefs.h: add artificial attribute to FORTIFY_SOURCE functions"
Broke the build. In file included from frameworks/rs/cpu_ref/rsCpuCore.cpp:36: system/core/include/cutils/properties.h:118:1: error: unknown attribute '__artificial__' ignored [-Werror,-Wunknown-attributes] __BIONIC_FORTIFY_INLINE ^ bionic/libc/include/sys/cdefs.h:537:110: note: expanded from macro '__BIONIC_FORTIFY_INLINE' #define __BIONIC_FORTIFY_INLINE extern __inline__ __always_inline __attribute__((gnu_inline)) __attribute__((__artificial__)) ^ 1 error generated. make: *** [out/target/product/generic/obj/SHARED_LIBRARIES/libRSCpuRef_intermediates/rsCpuCore.o] Error 1 This reverts commit 9b543ffeac216189cc8125f7624da9a8cbcbe2e4. Change-Id: I6a1198747505dcb402b722887c1bfbc3a628a8b8
Diffstat (limited to 'tests/fortify_test.cpp')
-rw-r--r--tests/fortify_test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 554a11247..352cac694 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -120,6 +120,17 @@ TEST_F(DEATHTEST, sprintf_fortified2) {
#endif
#ifndef __clang__
+// This test is disabled in clang because clang doesn't properly detect
+// this buffer overflow. TODO: Fix clang.
+TEST_F(DEATHTEST, sprintf2_fortified2) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ foo myfoo;
+ ASSERT_EXIT(sprintf(myfoo.a, "0123456789"),
+ testing::KilledBySignal(SIGABRT), "");
+}
+#endif
+
+#ifndef __clang__
// These tests are disabled in clang because clang doesn't properly detect
// this buffer overflow. TODO: Fix clang.
static int vsprintf_helper2(const char *fmt, ...) {
@@ -516,6 +527,12 @@ TEST_F(DEATHTEST, sprintf_malloc_fortified) {
}
#endif
+TEST_F(DEATHTEST, sprintf2_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[5];
+ ASSERT_EXIT(sprintf(buf, "aaaaa"), testing::KilledBySignal(SIGABRT), "");
+}
+
static int vsprintf_helper(const char *fmt, ...) {
char buf[10];
va_list va;
@@ -682,6 +699,16 @@ 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) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[1];
+ fd_set* set = (fd_set*) buf;
+ ASSERT_EXIT(FD_ZERO_function(set), testing::KilledBySignal(SIGABRT), "");
+}
+
TEST_F(DEATHTEST, read_fortified) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
char buf[1];