libc: upgrade sprintf to _FORTIFY_SOURCE=2

Upgrade sprintf to fortify_source level 2, to catch
additional security bugs.

Change-Id: Ibc957d65e4cb96152de84b3745a04e00fa22659e
This commit is contained in:
Nick Kralevich
2013-04-29 16:29:37 -07:00
parent 382a775378
commit 78d6d9888c
4 changed files with 33 additions and 4 deletions

View File

@@ -52,3 +52,11 @@ TEST(Fortify1_DeathTest, strrchr_fortified) {
ASSERT_EXIT(printf("%s", strrchr(buf, 'a')), testing::KilledBySignal(SIGSEGV), "");
}
#endif
TEST(Fortify1_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(SIGSEGV), "");
}