Commit cf94032b authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed possible string over-indexing in is_utf8 function



Change-Id: I901e88cc6ff5bf0424a98dab62954d3fce95aaf0
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent f76158be
......@@ -818,7 +818,7 @@ static CharCoding::CharCodingType is_utf8(size_t length, const unsigned char* st
// the second and third (and so on) UTF-8 byte looks like 10xx xxxx
while (0 < noofUTF8 ) {
++i;
if (!(strptr[i] & MSB) || (strptr[i] & MSBmin1) || i >= length) { // if not like this: 10xx xxxx
if (i >= length || !(strptr[i] & MSB) || (strptr[i] & MSBmin1)) { // if not like this: 10xx xxxx
return CharCoding::UNKNOWN;
}
--noofUTF8;
......
......@@ -239,7 +239,7 @@ static CharCoding::CharCodingType is_utf8 ( const OCTETSTRING& ostr )
while (0 < noofUTF8 ) {
++i;
//std::cout << "mask & strptr[" << i << "] " << std::hex << (int)strptr[i] << std::endl;
if (!(strptr[i] & MSB) || (strptr[i] & MSBmin1) || i >= ostr.lengthof()) { // if not like this: 10xx xxxx
if (i >= ostr.lengthof() || !(strptr[i] & MSB) || (strptr[i] & MSBmin1)) { // if not like this: 10xx xxxx
return CharCoding::UNKNOWN;
}
--noofUTF8;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment