clean up FORTIFY_SOURCE handling.
Avoid duplicating huge chunks of code.
Change-Id: Id6145cdfce781c5ffba2abaaa79681d25a7ab28f
diff --git a/libc/bionic/__strncat_chk.cpp b/libc/bionic/__strncat_chk.cpp
index 2ba8550..32a3962 100644
--- a/libc/bionic/__strncat_chk.cpp
+++ b/libc/bionic/__strncat_chk.cpp
@@ -55,17 +55,13 @@
size_t sum;
// sum = src_len + dest_len + 1 (with overflow protection)
if (!safe_add3(&sum, src_len, dest_len, 1U)) {
- __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
- "*** strncat integer overflow detected ***\n");
- __libc_android_log_event_uid(BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW);
- abort();
+ __fortify_chk_fail("strncat integer overflow",
+ BIONIC_EVENT_STRNCAT_INTEGER_OVERFLOW);
}
if (sum > dest_buf_size) {
- __libc_android_log_print(ANDROID_LOG_FATAL, "libc",
- "*** strncat buffer overflow detected ***\n");
- __libc_android_log_event_uid(BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
- abort();
+ __fortify_chk_fail("strncat buffer overflow",
+ BIONIC_EVENT_STRNCAT_BUFFER_OVERFLOW);
}
return strncat(dest, src, len);