Loading
Harden InputMethodInfo parsing against large metadata
An IME's metadata can reference arbitrarily large strings (e.g.,
@string/large_text), which can lead to OOM or large Binder transactions
during parsing. The previous check only validated the raw XML file
size, failing to account for the size of these resolved string
references.
This patch hardens the InputMethodInfo constructor by enforcing a 200KB
cumulative limit on all resolved metadata attributes. A new
MetadataReadBytesTracker now sums the actual size of all read
attributes, including the full length of any strings, and parsing is
aborted if this 200KB limit is exceeded.
Bug: 449416164
Bug: 449181366
Bug: 449393786
Bug: 449227003
Test: CtsInputMethodTestCases:{InputMethodRegistrationTest,InputMethodInfoTest}
Test: InputMethodCoreTests:{InputMethodSubtypeArrayTest,InputMethodInfoTest}
Flag: EXEMPT BUGFIX
(cherry picked from commit 7afc13faace7cfafd0353482db33504c5e269d69)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:311c7f2c2b8b927571884765c7322a21f8115383
Merged-In: I43f7be8eb80abeb39863a3b01d3a606beb90120c
Change-Id: I43f7be8eb80abeb39863a3b01d3a606beb90120c