Add a test and remove a work-around for a fixed bug
The ASN.1 parser for a date-time had to check the date-time string was all digits to catch the case of a sign in the month field, which used to be accepted when it should not be. That bug has now been fixed, so remove the work-around and add a second date-time test-case, renaming (and modernising) the existing one for consistency. Task-number: QTBUG-84349 Change-Id: I649c5129312b6865af08b22ba6893cb4e29243f8 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>bb10
parent
1b6874034a
commit
299186602a
|
|
@ -261,13 +261,6 @@ QDateTime QAsn1Element::toDateTime() const
|
|||
if (mValue.back() != 'Z')
|
||||
return result;
|
||||
|
||||
// In addition, check that we only have digits representing the
|
||||
// date/time. This should not really be necessary (there's no such
|
||||
// thing as negative months/days/etc.); it's a workaround for
|
||||
// QTBUG-84349.
|
||||
if (!std::all_of(mValue.begin(), mValue.end() - 1, isAsciiDigit))
|
||||
return result;
|
||||
|
||||
if (mType == UtcTimeType && mValue.size() == 13) {
|
||||
result = QDateTime::fromString(QString::fromLatin1(mValue),
|
||||
QStringLiteral("yyMMddHHmmsst"));
|
||||
|
|
|
|||
|
|
@ -2908,10 +2908,11 @@ void tst_QDateTime::fromStringStringFormat_data()
|
|||
<< QString(u8"yyyy🤣MM🤣ddThh🤣mm🤣ss.zt")
|
||||
<< QDateTime(QDate(2005, 6, 28), QTime(7, 57, 30, 1), Qt::UTC);
|
||||
|
||||
// QTBUG-84349
|
||||
QTest::newRow("QTBUG-84349: positive sign in month")
|
||||
<< QStringLiteral("9922+221102233Z") << QStringLiteral("yyyyMMddHHmmsst")
|
||||
<< QDateTime();
|
||||
// Two tests derived from malformed ASN.1 strings (QTBUG-84349):
|
||||
QTest::newRow("ASN.1:UTC")
|
||||
<< u"22+221102233Z"_qs << u"yyMMddHHmmsst"_qs << QDateTime();
|
||||
QTest::newRow("ASN.1:Generalized")
|
||||
<< u"9922+221102233Z"_qs << u"yyyyMMddHHmmsst"_qs << QDateTime();
|
||||
|
||||
// fuzzer test
|
||||
QTest::newRow("integer overflow found by fuzzer")
|
||||
|
|
|
|||
Loading…
Reference in New Issue