Skip to content

Commit

Permalink
Fixed|libcore|String: Out-of-bounds memory access (leading to crash)
Browse files Browse the repository at this point in the history
String::compareWithCase() was calling the QString constructor with a
specific size with the intention of limiting the size of the string.
However, this constructor does not check for null-termination in this
case.

IssueID #1879
  • Loading branch information
skyjake committed Nov 8, 2014
1 parent 0310fec commit 95d2051
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doomsday/libcore/src/data/string.cpp
Expand Up @@ -416,7 +416,7 @@ dint String::compareWithoutCase(String const &str) const

dint String::compareWithoutCase(const String &str, int n) const
{
return left(n).compare(str.left(n), Qt::CaseInsensitive);
return leftRef(n).compare(str.leftRef(n), Qt::CaseInsensitive);
}

int String::commonPrefixLength(String const &str, Qt::CaseSensitivity sensitivity) const
Expand All @@ -439,7 +439,7 @@ int String::commonPrefixLength(String const &str, Qt::CaseSensitivity sensitivit

dint String::compareWithCase(QChar const *a, QChar const *b, dsize count)
{
return QString(a, int(count)).compare(QString(b, int(count)), Qt::CaseSensitive);
return QString(a).leftRef(count).compare(QString(b).leftRef(count), Qt::CaseSensitive);
}

void String::skipSpace(String::const_iterator &i, String::const_iterator const &end)
Expand Down

0 comments on commit 95d2051

Please sign in to comment.