From cc6719f08251a892e435f8d9d44e9d8fa18d7cbe Mon Sep 17 00:00:00 2001 From: Jeff Hamilton Date: Tue, 1 Sep 2009 00:29:12 -0500 Subject: Avoid a buffer overrun in GET_NORMALIZED_STRING. This custom SQL function uses a fixed buffer of 128 characters and would overrun the buffer if passed a longer src string. Also, fix another problem with the function where it was using the incorrect value for next_codepoint. It was reading from the destination array not the source array. Bug: 2089658 --- android/PhoneticStringUtilsTest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'android/PhoneticStringUtilsTest.cpp') diff --git a/android/PhoneticStringUtilsTest.cpp b/android/PhoneticStringUtilsTest.cpp index 356342e..9d06327 100644 --- a/android/PhoneticStringUtilsTest.cpp +++ b/android/PhoneticStringUtilsTest.cpp @@ -39,6 +39,7 @@ class TestExecutor { void testGetUtf8FromUtf32(); void testGetPhoneticallySortableString(); void testGetNormalizedString(); + void testLongString(); // Note: When adding a test, do not forget to add it to DoOneTest(). @@ -75,6 +76,7 @@ bool TestExecutor::DoAllTests() { DoOneTest(&TestExecutor::testGetUtf8FromUtf32); DoOneTest(&TestExecutor::testGetPhoneticallySortableString); DoOneTest(&TestExecutor::testGetNormalizedString); + DoOneTest(&TestExecutor::testLongString); printf("Test total: %d\nSuccess: %d\nFailure: %d\n", m_total_count, m_success_count, m_total_count - m_success_count); @@ -415,6 +417,15 @@ void TestExecutor::testGetNormalizedString() { EXPECT_EQ_UTF8_UTF8(" \t", " \t"); } +void TestExecutor::testLongString() { + printf("testLongString()\n"); + char * dst; + size_t len; + EXPECT_EQ_UTF8_UTF8("Qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqtttttttttttttttttttttttttttttttttttttttttttttttttgggggggggggggggggggggggggggggggggggggggbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + "Qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqtttttttttttttttttttttttttttttttttttttttttttttttttggggggggggggggggggggggggggggggggggg"); +} + + int main() { TestExecutor executor; if(executor.DoAllTests()) { -- cgit v1.2.3