Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97777

Assertion violation in QDateTime parsing.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.2.0
    • Core: Date/Time
    • None
    • macOS 12.0.1
    • macOS
    • 97cba363f99bec3174e305a714d4cdcabb147838 (qt/qtbase/6.2)

    Description

      In self-built Qt 6.2 on macOS I get a crash on a line:

      QDateTime::fromString("200507065922Z", "yyMMddHHmmsst")
      

      The assertion is this:

      Q_ASSERT(([data](qint64 offset) {
          return offset == data.offsetFromUtc
              // When zoneMSecs falls in a spring-forward's gap:
              || offset == data.standardTimeOffset
              // When it falls in the gap leading into double-DST:
              || offset == 2 * data.standardTimeOffset
              // When it falls in a skipped day (Pacific date-line crossings):
              || (data.offsetFromUtc - offset) % SECS_PER_DAY == 0;
      })((zoneMSecs - data.atMSecsSinceEpoch) / MSECS_PER_SEC));
      

      It shows such fields:

      • zoneMSecs = -1577923200000
      • data.atMSecsSinceEpoch = -1577937600000
      • data.offsetFromUtc = 13272
      • data.standardTimeOffset = 13272
      • data.daylightTimeOffset = 0

      This happens when reading information about X509 certificate, in:

      • X509CertificateGeneric::parse
      • QAsn1Element::toDateTime

      When reading notValidBefore and notValidAfter.

      Also, this code works in Qt 5.15.2 (because there is no such assert), but it produces a date with year 1920 in both Qt 5.15.2 and Qt 6.2 (if I comment out this assertion).

      I think this is invalid date being parsed, because UTCTime in this format should parse to 2020 year, not 1920.

      Attachments

        For Gerrit Dashboard: QTBUG-97777
        # Subject Branch Project Status CR V

        Activity

          People

            Eddy Edward Welbourne
            johnpreston John Preston
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes