Skip to content

Commit f0ea4c8

Browse files
Sergio Girogitbuildkicker
authored andcommitted
Add bound checks to utf16_to_utf8
Test: ran libaapt2_tests64 Bug: 29250543 Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3 (cherry picked from commit 4781057)
1 parent 28460c2 commit f0ea4c8

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

tools/aapt/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ aaptHostLdLibs :=
6363
aaptHostStaticLibs := \
6464
libandroidfw \
6565
libpng \
66-
liblog \
6766
libutils \
67+
liblog \
6868
libcutils \
6969
libexpat \
7070
libziparchive-host \

tools/aapt2/Util.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,10 @@ std::string utf16ToUtf8(const StringPiece16& utf16) {
303303
}
304304

305305
std::string utf8;
306+
// Make room for '\0' explicitly.
307+
utf8.resize(utf8Length + 1);
308+
utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin(), utf8Length + 1);
306309
utf8.resize(utf8Length);
307-
utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin());
308310
return utf8;
309311
}
310312

tools/split-select/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ hostStaticLibs := \
4848
libaapt \
4949
libandroidfw \
5050
libpng \
51-
liblog \
5251
libutils \
52+
liblog \
5353
libcutils \
5454
libexpat \
5555
libziparchive-host \

0 commit comments

Comments
 (0)