Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-core: Commit

system/core


Commit MetaInfo

Revision4105d377f4552a702de48051208926b08e574d17 (tree)
Time2018-05-25 19:29:03
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

Android 8.1.0 Release 29 (OPM4.171019.016.C1)
-----BEGIN PGP SIGNATURE-----

iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCWui7+gAKCRDorT+BmrEO
eDW0AJ0arUDfIL/1furGV/nnWmOHhGE3XQCfYQ2ylzAzvZh8X1+hZwNl4fUDMwU=
=ScFO
-----END PGP SIGNATURE-----

Merge tag 'android-8.1.0_r29' into oreo-x86

Android 8.1.0 Release 29 (OPM4.171019.016.C1)

Change Summary

Incremental Difference

--- a/libutils/String16.cpp
+++ b/libutils/String16.cpp
@@ -79,6 +79,23 @@ static char16_t* allocFromUTF8(const char* u8str, size_t u8len)
7979 return getEmptyString();
8080 }
8181
82+static char16_t* allocFromUTF16(const char16_t* u16str, size_t u16len) {
83+ if (u16len >= SIZE_MAX / sizeof(char16_t)) {
84+ android_errorWriteLog(0x534e4554, "73826242");
85+ abort();
86+ }
87+
88+ SharedBuffer* buf = SharedBuffer::alloc((u16len + 1) * sizeof(char16_t));
89+ ALOG_ASSERT(buf, "Unable to allocate shared buffer");
90+ if (buf) {
91+ char16_t* str = (char16_t*)buf->data();
92+ memcpy(str, u16str, u16len * sizeof(char16_t));
93+ str[u16len] = 0;
94+ return str;
95+ }
96+ return getEmptyString();
97+}
98+
8299 // ---------------------------------------------------------------------------
83100
84101 String16::String16()
@@ -111,35 +128,9 @@ String16::String16(const String16& o, size_t len, size_t begin)
111128 setTo(o, len, begin);
112129 }
113130
114-String16::String16(const char16_t* o)
115-{
116- size_t len = strlen16(o);
117- SharedBuffer* buf = SharedBuffer::alloc((len+1)*sizeof(char16_t));
118- ALOG_ASSERT(buf, "Unable to allocate shared buffer");
119- if (buf) {
120- char16_t* str = (char16_t*)buf->data();
121- strcpy16(str, o);
122- mString = str;
123- return;
124- }
125-
126- mString = getEmptyString();
127-}
128-
129-String16::String16(const char16_t* o, size_t len)
130-{
131- SharedBuffer* buf = SharedBuffer::alloc((len+1)*sizeof(char16_t));
132- ALOG_ASSERT(buf, "Unable to allocate shared buffer");
133- if (buf) {
134- char16_t* str = (char16_t*)buf->data();
135- memcpy(str, o, len*sizeof(char16_t));
136- str[len] = 0;
137- mString = str;
138- return;
139- }
131+String16::String16(const char16_t* o) : mString(allocFromUTF16(o, strlen16(o))) {}
140132
141- mString = getEmptyString();
142-}
133+String16::String16(const char16_t* o, size_t len) : mString(allocFromUTF16(o, len)) {}
143134
144135 String16::String16(const String8& o)
145136 : mString(allocFromUTF8(o.string(), o.size()))
@@ -201,6 +192,11 @@ status_t String16::setTo(const char16_t* other)
201192
202193 status_t String16::setTo(const char16_t* other, size_t len)
203194 {
195+ if (len >= SIZE_MAX / sizeof(char16_t)) {
196+ android_errorWriteLog(0x534e4554, "73826242");
197+ abort();
198+ }
199+
204200 SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
205201 ->editResize((len+1)*sizeof(char16_t));
206202 if (buf) {
@@ -224,6 +220,11 @@ status_t String16::append(const String16& other)
224220 return NO_ERROR;
225221 }
226222
223+ if (myLen >= SIZE_MAX / sizeof(char16_t) - otherLen) {
224+ android_errorWriteLog(0x534e4554, "73826242");
225+ abort();
226+ }
227+
227228 SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
228229 ->editResize((myLen+otherLen+1)*sizeof(char16_t));
229230 if (buf) {
@@ -245,6 +246,11 @@ status_t String16::append(const char16_t* chrs, size_t otherLen)
245246 return NO_ERROR;
246247 }
247248
249+ if (myLen >= SIZE_MAX / sizeof(char16_t) - otherLen) {
250+ android_errorWriteLog(0x534e4554, "73826242");
251+ abort();
252+ }
253+
248254 SharedBuffer* buf = SharedBuffer::bufferFromData(mString)
249255 ->editResize((myLen+otherLen+1)*sizeof(char16_t));
250256 if (buf) {
Show on old repository browser