summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-06-28 18:26:10 +0100
committergitbuildkicker <android-build@google.com>2016-07-21 17:34:52 -0700
commitf0ea4c8737ec911074cc4d284f984c5c353f32e2 (patch)
tree0f19f2d541dca7380ba3a90057ecc4f6c952f59e /tools
parent28460c294ebd9c9cab258c92a20e0e2cc63e64f0 (diff)
downloadframeworks_base-f0ea4c8737ec911074cc4d284f984c5c353f32e2.zip
frameworks_base-f0ea4c8737ec911074cc4d284f984c5c353f32e2.tar.gz
frameworks_base-f0ea4c8737ec911074cc4d284f984c5c353f32e2.tar.bz2
Add bound checks to utf16_to_utf8
Test: ran libaapt2_tests64 Bug: 29250543 Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3 (cherry picked from commit 4781057e78f63e0e99af109cebf3b6a78f4bfbb6)
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/Android.mk2
-rw-r--r--tools/aapt2/Util.cpp4
-rw-r--r--tools/split-select/Android.mk2
3 files changed, 5 insertions, 3 deletions
diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk
index b991d55..08cbd5a 100644
--- a/tools/aapt/Android.mk
+++ b/tools/aapt/Android.mk
@@ -63,8 +63,8 @@ aaptHostLdLibs :=
aaptHostStaticLibs := \
libandroidfw \
libpng \
- liblog \
libutils \
+ liblog \
libcutils \
libexpat \
libziparchive-host \
diff --git a/tools/aapt2/Util.cpp b/tools/aapt2/Util.cpp
index 03ecd1a..5b064e3 100644
--- a/tools/aapt2/Util.cpp
+++ b/tools/aapt2/Util.cpp
@@ -303,8 +303,10 @@ std::string utf16ToUtf8(const StringPiece16& utf16) {
}
std::string utf8;
+ // Make room for '\0' explicitly.
+ utf8.resize(utf8Length + 1);
+ utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin(), utf8Length + 1);
utf8.resize(utf8Length);
- utf16_to_utf8(utf16.data(), utf16.length(), &*utf8.begin());
return utf8;
}
diff --git a/tools/split-select/Android.mk b/tools/split-select/Android.mk
index d9ddf08..54f0a1f 100644
--- a/tools/split-select/Android.mk
+++ b/tools/split-select/Android.mk
@@ -48,8 +48,8 @@ hostStaticLibs := \
libaapt \
libandroidfw \
libpng \
- liblog \
libutils \
+ liblog \
libcutils \
libexpat \
libziparchive-host \