Remove an unfounded assertion, add the test-case that tripped it
The date-time parser, unless it hits a fixed-width numeric field that's unfilled, leaves checking the date against its configured range until it's parsed all fields. This means it can be out of range due to a full-width field when it hits an unfilled one and tries to take the range into account when deciding whether to zero-pad or expect more input into the field. So asserting the current partially-parsed datetime is in range at that point is not justified. Thanks to Albert Astals Cid for reporting this fiendish corner case, found by oss-fuzzing of KDE's image plugins, in IRC. Pick-to: 6.7 6.5 6.2 5.15 Change-Id: Id7db7409a0b5afadafb6920a0785a4cec4c80b62 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Albert Astals Cid <aacid@kde.org> (cherry picked from commit e0a4de17ddb924d9bf222fb3ea2d0526813edea6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
88f3fd0f75
commit
e7db7a68f6
@ -2161,7 +2161,10 @@ bool QDateTimeParser::skipToNextSection(int index, const QDateTime ¤t, QSt
|
||||
if (node.type != TimeZoneSection || current.timeSpec() == Qt::OffsetFromUTC) {
|
||||
const QDateTime maximum = getMaximum();
|
||||
const QDateTime minimum = getMinimum();
|
||||
Q_ASSERT(current >= minimum && current <= maximum);
|
||||
// Range from minimum to maximum might not contain current if an earlier
|
||||
// field's value was full-width but out of range. In such a case the
|
||||
// parse is already headed for Invalid, so it doesn't matter that we get
|
||||
// the wrong range of values for the current field here.
|
||||
|
||||
QDateTime tmp = current;
|
||||
if (!setDigit(tmp, index, min) || tmp < minimum)
|
||||
|
@ -3271,6 +3271,8 @@ void tst_QDateTime::fromStringStringFormat_data()
|
||||
<< u"2008-10-13 UTC+01:011.50"_s << u"yyyy-MM-dd thh.mm"_s << 1900 << QDateTime();
|
||||
QTest::newRow("invalid-time-spec:empty")
|
||||
<< u"2001-09-15T09:33:01.001 "_s << u"yyyy-MM-ddThh:mm:ss.z t"_s << 1900 << QDateTime();
|
||||
QTest::newRow("invalid-month-year<min") // This used to fail an unfounded assertion.
|
||||
<< u"0024:91:06 08:52:20"_s << u"yyyy:MM:dd HH:mm:ss"_s << 1900 << QDateTime();
|
||||
#if QT_CONFIG(timezone)
|
||||
QTimeZone southBrazil("America/Sao_Paulo");
|
||||
if (southBrazil.isValid()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user