am 5fed0eea: am 0ce28d20: Merge "libc: enable FORTIFY_SOURCE clang strlcpy"

* commit '5fed0eeabd88bfe241c416f2c2f44a14b6e447fa':
  libc: enable FORTIFY_SOURCE clang strlcpy
This commit is contained in:
Nick Kralevich
2013-06-20 12:34:11 -07:00
committed by Android Git Automerger
4 changed files with 42 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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) {