diff options
author | Nick Kralevich <nnk@google.com> | 2013-06-20 12:17:44 -0700 |
---|---|---|
committer | Nick Kralevich <nnk@google.com> | 2013-06-20 12:17:44 -0700 |
commit | 8bafa7452ec0892572b0b49f86022ce945c5e908 (patch) | |
tree | 92c021e3852b1f8b5cee464c5ff5500c84eb0f80 /tests | |
parent | 4eed65090b1f0d0d087f26bd7367da90a0cca92d (diff) | |
download | bionic-8bafa7452ec0892572b0b49f86022ce945c5e908.zip bionic-8bafa7452ec0892572b0b49f86022ce945c5e908.tar.gz bionic-8bafa7452ec0892572b0b49f86022ce945c5e908.tar.bz2 |
libc: enable FORTIFY_SOURCE clang strlcpy
Change-Id: Idcfe08f5afc3dde592416df9eba83f64e130c7c2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fortify1_test.cpp | 10 | ||||
-rw-r--r-- | tests/fortify1_test_clang.cpp | 10 | ||||
-rw-r--r-- | tests/fortify2_test.cpp | 20 |
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/fortify1_test.cpp b/tests/fortify1_test.cpp index be59a18..b8751bb 100644 --- a/tests/fortify1_test.cpp +++ b/tests/fortify1_test.cpp @@ -80,6 +80,16 @@ TEST(Fortify1_DeathTest, strrchr_fortified) { memcpy(buf, "0123456789", sizeof(buf)); ASSERT_EXIT(printf("%s", strrchr(buf, 'a')), testing::KilledBySignal(SIGABRT), ""); } + +TEST(Fortify1_DeathTest, strlcpy_fortified) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + char bufa[15]; + char bufb[10]; + strcpy(bufa, "01234567890123"); + size_t n = strlen(bufa); + ASSERT_EXIT(strlcpy(bufb, bufa, n), testing::KilledBySignal(SIGABRT), ""); +} + #endif TEST(Fortify1_DeathTest, sprintf_fortified) { diff --git a/tests/fortify1_test_clang.cpp b/tests/fortify1_test_clang.cpp index 0c0fb2b..fed9f13 100644 --- a/tests/fortify1_test_clang.cpp +++ b/tests/fortify1_test_clang.cpp @@ -80,6 +80,16 @@ TEST(Fortify1_Clang_DeathTest, strrchr_fortified) { memcpy(buf, "0123456789", sizeof(buf)); ASSERT_EXIT(printf("%s", strrchr(buf, 'a')), testing::KilledBySignal(SIGABRT), ""); } + +TEST(Fortify1_Clang_DeathTest, strlcpy_fortified) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + char bufa[15]; + char bufb[10]; + strcpy(bufa, "01234567890123"); + size_t n = strlen(bufa); + ASSERT_EXIT(strlcpy(bufb, bufa, n), testing::KilledBySignal(SIGABRT), ""); +} + #endif TEST(Fortify1_Clang_DeathTest, strncat_fortified) { diff --git a/tests/fortify2_test.cpp b/tests/fortify2_test.cpp index b48a077..b6f6661 100644 --- a/tests/fortify2_test.cpp +++ b/tests/fortify2_test.cpp @@ -94,6 +94,16 @@ TEST(Fortify2_DeathTest, strrchr_fortified2) { ASSERT_EXIT(printf("%s", strrchr(myfoo.a, 'a')), testing::KilledBySignal(SIGABRT), ""); } + +TEST(Fortify2_DeathTest, strlcpy_fortified2) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + foo myfoo; + strcpy(myfoo.a, "01"); + size_t n = strlen(myfoo.a); + ASSERT_EXIT(strlcpy(myfoo.one, myfoo.a, n), + testing::KilledBySignal(SIGABRT), ""); +} + #endif TEST(Fortify2_DeathTest, strncat_fortified2) { @@ -199,6 +209,16 @@ TEST(Fortify2_DeathTest, strrchr_fortified) { memcpy(buf, "0123456789", sizeof(buf)); ASSERT_EXIT(printf("%s", strrchr(buf, 'a')), testing::KilledBySignal(SIGABRT), ""); } + +TEST(Fortify2_DeathTest, strlcpy_fortified) { + ::testing::FLAGS_gtest_death_test_style = "threadsafe"; + char bufa[15]; + char bufb[10]; + strcpy(bufa, "01234567890123"); + size_t n = strlen(bufa); + ASSERT_EXIT(strlcpy(bufb, bufa, n), testing::KilledBySignal(SIGABRT), ""); +} + #endif TEST(Fortify2_DeathTest, sprintf_fortified) { |