diff options
author | Jeff Hamilton <jham@android.com> | 2009-09-01 00:29:12 -0500 |
---|---|---|
committer | Jeff Hamilton <jham@android.com> | 2009-09-01 00:29:12 -0500 |
commit | cc6719f08251a892e435f8d9d44e9d8fa18d7cbe (patch) | |
tree | 23ba1c0702542e3f648cfb4126ec63565e5b2537 /android/PhoneticStringUtilsTest.cpp | |
parent | b020ccd8772182ddfccba30b5adbc500982b59c1 (diff) |
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
Diffstat (limited to 'android/PhoneticStringUtilsTest.cpp')
-rw-r--r-- | android/PhoneticStringUtilsTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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()) { |