Fix memchr overflow.

The overflow's actually in the generic C implementation of memchr.

While I'm here, let's switch our generic memrchr to the OpenBSD version too.

Bug: https://code.google.com/p/android/issues/detail?id=147048
Change-Id: I296ae06a1ee196d2c77c95a22f11ee4d658962da
This commit is contained in:
Elliott Hughes
2015-02-14 13:21:22 -08:00
parent f9fb52ab30
commit 41ef902379
10 changed files with 107 additions and 102 deletions

View File

@@ -1385,3 +1385,13 @@ TEST(string, __gnu_basename) {
TestBasename("///", "");
TestBasename("//usr//lib//", "");
}
TEST(string, strnlen_147048) {
// https://code.google.com/p/android/issues/detail?id=147048
char stack_src[64] = {0};
EXPECT_EQ(0U, strnlen(stack_src, 1024*1024*1024));
char* heap_src = new char[1];
*heap_src = '\0';
EXPECT_EQ(0U, strnlen(heap_src, 1024*1024*1024));
delete[] heap_src;
}