Add stack canaries / strcpy tests.
Add a test to ensure that stack canaries are working correctly. Since stack canaries aren't normally generated on non-string functions, we have to enable stack-protector-all. Add a test to ensure that an out of bounds strcpy generates a runtime failure. Change-Id: Id0d3e59fc4b9602da019e4d35c5c653e1a57fae4
This commit is contained in:
@@ -305,6 +305,19 @@ TEST(string, strcpy) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if __BIONIC__
|
||||
// We have to say "DeathTest" here so gtest knows to run this test (which exits)
|
||||
// in its own process.
|
||||
TEST(string_DeathTest, strcpy_fortified) {
|
||||
::testing::FLAGS_gtest_death_test_style = "threadsafe";
|
||||
char buf[10];
|
||||
char *orig = strdup("0123456789");
|
||||
ASSERT_EXIT(strcpy(buf, orig), testing::KilledBySignal(SIGSEGV), "");
|
||||
free(orig);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __BIONIC__
|
||||
TEST(string, strlcat) {
|
||||
StringTestState state(SMALL);
|
||||
|
Reference in New Issue
Block a user