libc: enable sprintf FORTIFY_SOURCE under clang

clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
This commit is contained in:
Nick Kralevich
2013-06-24 11:44:00 -07:00
parent 53ddcc9070
commit c6eb985454
5 changed files with 58 additions and 2 deletions

View File

@@ -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];