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
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 @@
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 @@
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 @@
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()) {