Add bound checks to utf16_to_utf8

Test: ran libaapt2_tests64
Bug: 29250543
Change-Id: I1ebc017af623b6514cf0c493e8cd8e1d59ea26c3
(cherry picked from commit 4781057e78)
This commit is contained in:
Sergio Giro
2016-06-28 18:26:10 +01:00
parent 6ae7a5f72b
commit bce11021b2
3 changed files with 5 additions and 3 deletions

View File

@@ -63,8 +63,8 @@ aaptHostLdLibs :=
aaptHostStaticLibs := \
libandroidfw \
libpng \
liblog \
libutils \
liblog \
libcutils \
libexpat \
libziparchive-host \

View File

@@ -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;
}

View File

@@ -48,8 +48,8 @@ hostStaticLibs := \
libaapt \
libandroidfw \
libpng \
liblog \
libutils \
liblog \
libcutils \
libexpat \
libziparchive-host \