summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2013-06-25 05:59:32 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-06-25 05:59:32 -0700
commit5f7f7fca278c45debe7e2fa80edd859277141f17 (patch)
tree43c8b64ddd3b819a21c13ce2d084558bb1c74837 /tests
parentde76bafb21477fbfac903abdc8154925da94b21e (diff)
parent954480393f4539f62cdc3f6cb83c562050ea4f51 (diff)
downloadbionic-5f7f7fca278c45debe7e2fa80edd859277141f17.zip
bionic-5f7f7fca278c45debe7e2fa80edd859277141f17.tar.gz
bionic-5f7f7fca278c45debe7e2fa80edd859277141f17.tar.bz2
am 95448039: am 0ea1d5c0: Merge "libc: enable sprintf FORTIFY_SOURCE under clang"
* commit '954480393f4539f62cdc3f6cb83c562050ea4f51': libc: enable sprintf FORTIFY_SOURCE under clang
Diffstat (limited to 'tests')
-rw-r--r--tests/fortify1_test.cpp6
-rw-r--r--tests/fortify1_test_clang.cpp14
-rw-r--r--tests/fortify2_test.cpp13
-rw-r--r--tests/fortify2_test_clang.cpp14
4 files changed, 47 insertions, 0 deletions
diff --git a/tests/fortify1_test.cpp b/tests/fortify1_test.cpp
index b8751bb..9d40404 100644
--- a/tests/fortify1_test.cpp
+++ b/tests/fortify1_test.cpp
@@ -100,6 +100,12 @@ TEST(Fortify1_DeathTest, sprintf_fortified) {
ASSERT_EXIT(sprintf(buf, "%s", source_buf), testing::KilledBySignal(SIGABRT), "");
}
+TEST(Fortify1_DeathTest, sprintf2_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[5];
+ ASSERT_EXIT(sprintf(buf, "aaaaa"), testing::KilledBySignal(SIGABRT), "");
+}
+
TEST(Fortify1_DeathTest, strncat_fortified) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
char buf[10];
diff --git a/tests/fortify1_test_clang.cpp b/tests/fortify1_test_clang.cpp
index fed9f13..b4ded33 100644
--- a/tests/fortify1_test_clang.cpp
+++ b/tests/fortify1_test_clang.cpp
@@ -92,6 +92,20 @@ TEST(Fortify1_Clang_DeathTest, strlcpy_fortified) {
#endif
+TEST(Fortify1_Clang_DeathTest, sprintf_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[10];
+ char source_buf[15];
+ memcpy(source_buf, "12345678901234", 15);
+ ASSERT_EXIT(sprintf(buf, "%s", source_buf), testing::KilledBySignal(SIGABRT), "");
+}
+
+TEST(Fortify1_Clang_DeathTest, sprintf2_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[5];
+ ASSERT_EXIT(sprintf(buf, "aaaaa"), testing::KilledBySignal(SIGABRT), "");
+}
+
TEST(Fortify1_Clang_DeathTest, strncat_fortified) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
char buf[10];
diff --git a/tests/fortify2_test.cpp b/tests/fortify2_test.cpp
index b6f6661..2f50038 100644
--- a/tests/fortify2_test.cpp
+++ b/tests/fortify2_test.cpp
@@ -46,6 +46,13 @@ TEST(Fortify2_DeathTest, sprintf_fortified2) {
testing::KilledBySignal(SIGABRT), "");
}
+TEST(Fortify2_DeathTest, sprintf2_fortified2) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ foo myfoo;
+ ASSERT_EXIT(sprintf(myfoo.a, "0123456789"),
+ testing::KilledBySignal(SIGABRT), "");
+}
+
#if __BIONIC__
// zero sized target with "\0" source (should fail)
TEST(Fortify2_DeathTest, strcpy_fortified2) {
@@ -229,6 +236,12 @@ TEST(Fortify2_DeathTest, sprintf_fortified) {
ASSERT_EXIT(sprintf(buf, "%s", source_buf), testing::KilledBySignal(SIGABRT), "");
}
+TEST(Fortify2_DeathTest, sprintf2_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[5];
+ ASSERT_EXIT(sprintf(buf, "aaaaa"), testing::KilledBySignal(SIGABRT), "");
+}
+
TEST(Fortify2_DeathTest, strncat_fortified) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
char buf[10];
diff --git a/tests/fortify2_test_clang.cpp b/tests/fortify2_test_clang.cpp
index d8a0ba6..54a6e5a 100644
--- a/tests/fortify2_test_clang.cpp
+++ b/tests/fortify2_test_clang.cpp
@@ -109,6 +109,20 @@ TEST(Fortify2_Clang_DeathTest, strrchr_fortified) {
}
#endif
+TEST(Fortify2_Clang_DeathTest, sprintf_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[10];
+ char source_buf[15];
+ memcpy(source_buf, "12345678901234", 15);
+ ASSERT_EXIT(sprintf(buf, "%s", source_buf), testing::KilledBySignal(SIGABRT), "");
+}
+
+TEST(Fortify2_Clang_DeathTest, sprintf2_fortified) {
+ ::testing::FLAGS_gtest_death_test_style = "threadsafe";
+ char buf[5];
+ ASSERT_EXIT(sprintf(buf, "aaaaa"), testing::KilledBySignal(SIGABRT), "");
+}
+
TEST(Fortify2_Clang_DeathTest, strncat_fortified) {
::testing::FLAGS_gtest_death_test_style = "threadsafe";
char buf[10];