QLatin1StringView: fix UB in "a"_L1 <> nullptr
Found by ubsan: if rhs is nullptr, then we fed a nullptr as the second argument of memcmp(), which is UB. Fix by catching an empty rhs before we reach that line. Amendsbb10e52d50a03d(which, despite pick-to's to the contrary, never made it into 6.2 or 5.15). Changeb977ae371afixed this for UTF-8/UTF-8 comparison from 6.5 on, but 6.4 ad 6.3 remain vulnerable there, but they're closed, so can't be fixed anymore. Pick-to: 6.7 6.5 Change-Id: I12fa986aa82a7440a9d53fad19a15e9420233e0b Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
parent
a910daf526
commit
89f184b403
|
|
@ -1543,6 +1543,8 @@ int QtPrivate::compareStrings(QLatin1StringView lhs, QLatin1StringView rhs, Qt::
|
|||
{
|
||||
if (lhs.isEmpty())
|
||||
return qt_lencmp(qsizetype(0), rhs.size());
|
||||
if (rhs.isEmpty())
|
||||
return qt_lencmp(lhs.size(), qsizetype(0));
|
||||
if (cs == Qt::CaseInsensitive)
|
||||
return latin1nicmp(lhs.data(), lhs.size(), rhs.data(), rhs.size());
|
||||
const auto l = std::min(lhs.size(), rhs.size());
|
||||
|
|
|
|||
Loading…
Reference in New Issue