diff options
author | Nick Kralevich <nnk@google.com> | 2013-01-11 11:03:40 -0800 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-01-11 11:03:40 -0800 |
commit | 69c89942db2ed472c71aa84903d0259cc84aa074 (patch) | |
tree | 881cf95d46f7894eaaa9b816a638fe7395602e00 /tests/string_test.cpp | |
parent | a12c54454f3a6132988b68873903f6e9eed7f384 (diff) | |
parent | dcab1b2c76a498c56bc00024613386de8b4b2aae (diff) |
Merge "Add stack canaries / strcpy tests."
Diffstat (limited to 'tests/string_test.cpp')
-rw-r--r-- | tests/string_test.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/string_test.cpp b/tests/string_test.cpp index d55771cf6..3f7d50019 100644 --- a/tests/string_test.cpp +++ b/tests/string_test.cpp @@ -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); |