diff options
author | Scott Lobdell <slobdell@google.com> | 2019-08-25 12:20:54 -0700 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2019-08-25 12:20:54 -0700 |
commit | 4f9bfdcaca2414c8959986f0a4d73f16cb15e1c4 (patch) | |
tree | 540bab5498d276cbbfad24c48a7ff989ee8b920a /tests/fortify_test.cpp | |
parent | bfda022dd6fbbcea60e9f52496d90ece514b32da (diff) | |
parent | f77cc9b224c35fa7d1d71e7c374ef19e47b5f6a5 (diff) |
Merge RP1A.190822.001
Change-Id: Iaf90835a99d87f6246798efd2cea6fe9f750ea18
Diffstat (limited to 'tests/fortify_test.cpp')
-rw-r--r-- | tests/fortify_test.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp index 489b7018d..9a4b781fc 100644 --- a/tests/fortify_test.cpp +++ b/tests/fortify_test.cpp @@ -926,6 +926,24 @@ TEST(TEST_NAME, strcat_chk_max_int_size) { ASSERT_EQ('\0', buf[9]); } +TEST(TEST_NAME, mempcpy_chk) { + const char input_str[] = "abcdefg"; + size_t input_str_size = strlen(input_str) + 1; + + char buf1[10] = {}; + char buf2[10] = {}; + + __builtin_mempcpy(buf1, input_str, input_str_size); + __builtin___mempcpy_chk(buf2, input_str, input_str_size, __bos0(buf2)); + + ASSERT_EQ(memcmp(buf1, buf2, sizeof(buf2)), 0); + + void *builtin_ptr = __builtin_mempcpy(buf1, input_str, input_str_size); + void *fortify_ptr = __builtin___mempcpy_chk(buf1, input_str, input_str_size, __bos0(buf2)); + + ASSERT_EQ(builtin_ptr, fortify_ptr); +} + extern "C" char* __stpcpy_chk(char*, const char*, size_t); TEST(TEST_NAME, stpcpy_chk_max_int_size) { |