clean up FORTIFY_SOURCE handling.

Avoid duplicating huge chunks of code.

Change-Id: Id6145cdfce781c5ffba2abaaa79681d25a7ab28f
This commit is contained in:
Nick Kralevich
2012-12-04 13:55:19 -08:00
parent db79e827eb
commit 326ea5413d
18 changed files with 43 additions and 70 deletions

View File

@@ -35,11 +35,8 @@ char *
__strchr_chk(const char *p, int ch, size_t s_len)
{
for (;; ++p, s_len--) {
if (s_len == 0) {
__libc_android_log_print(ANDROID_LOG_FATAL, "libc",
"*** FORTIFY_SOURCE strchr read beyond buffer ***\n");
abort();
}
if (s_len == 0)
__fortify_chk_fail("strchr read beyond buffer", 0);
if (*p == (char) ch)
return((char *)p);
if (!*p)

View File

@@ -37,11 +37,8 @@ __strrchr_chk(const char *p, int ch, size_t s_len)
char *save;
for (save = NULL;; ++p, s_len--) {
if (s_len == 0) {
__libc_android_log_print(ANDROID_LOG_FATAL, "libc",
"*** FORTIFY_SOURCE strrchr read beyond buffer ***\n");
abort();
}
if (s_len == 0)
__fortify_chk_fail("strrchr read beyond buffer", 0);
if (*p == (char) ch)
save = (char *)p;
if (!*p)