mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-14 02:14:34 -05:00
49 lines
2.1 KiB
Diff
49 lines
2.1 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Keith Mok <keithmok@google.com>
|
||
|
Date: Thu, 15 Sep 2022 22:51:42 +0000
|
||
|
Subject: [PATCH] Fix OOB read for registerLocaleList
|
||
|
|
||
|
When the buffer size is equal to string size,
|
||
|
the func in icu just return warning U_STRING_NOT_TERMINATED_WARNING
|
||
|
which is a negative number, and U_FAILURE would fail if error number
|
||
|
greater than zero only.
|
||
|
|
||
|
This would cause non null terminated string passing into following funcs
|
||
|
and causing different types of crash
|
||
|
|
||
|
Bug: 239210579
|
||
|
Bug: 239328580
|
||
|
Bug: 239267173
|
||
|
Test: locale_fuzzer
|
||
|
Ignore-AOSP-First: security
|
||
|
Merged-In: Id9c98fc08876656e1f48d12823a24bb7a44bee45
|
||
|
Change-Id: Id9c98fc08876656e1f48d12823a24bb7a44bee45
|
||
|
(cherry picked from commit d8a427cc9c8a722b0911af5139b10b0a6aeb0e03)
|
||
|
Merged-In: Id9c98fc08876656e1f48d12823a24bb7a44bee45
|
||
|
---
|
||
|
libs/minikin/LocaleListCache.cpp | 4 ++--
|
||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/libs/minikin/LocaleListCache.cpp b/libs/minikin/LocaleListCache.cpp
|
||
|
index c191ea6..5bd869e 100644
|
||
|
--- a/libs/minikin/LocaleListCache.cpp
|
||
|
+++ b/libs/minikin/LocaleListCache.cpp
|
||
|
@@ -42,7 +42,7 @@ static size_t toLanguageTag(char* output, size_t outSize, const StringPiece& loc
|
||
|
size_t outLength = 0;
|
||
|
UErrorCode uErr = U_ZERO_ERROR;
|
||
|
outLength = uloc_canonicalize(localeString.c_str(), output, outSize, &uErr);
|
||
|
- if (U_FAILURE(uErr)) {
|
||
|
+ if (U_FAILURE(uErr) || (uErr == U_STRING_NOT_TERMINATED_WARNING)) {
|
||
|
// unable to build a proper locale identifier
|
||
|
ALOGD("uloc_canonicalize(\"%s\") failed: %s", localeString.c_str(), u_errorName(uErr));
|
||
|
output[0] = '\0';
|
||
|
@@ -68,7 +68,7 @@ static size_t toLanguageTag(char* output, size_t outSize, const StringPiece& loc
|
||
|
|
||
|
uErr = U_ZERO_ERROR;
|
||
|
outLength = uloc_toLanguageTag(likelyChars, output, outSize, FALSE, &uErr);
|
||
|
- if (U_FAILURE(uErr)) {
|
||
|
+ if (U_FAILURE(uErr) || (uErr == U_STRING_NOT_TERMINATED_WARNING)) {
|
||
|
// unable to build a proper locale identifier
|
||
|
ALOGD("uloc_toLanguageTag(\"%s\") failed: %s", likelyChars, u_errorName(uErr));
|
||
|
output[0] = '\0';
|