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

[REG 6.4 -> 6.5] Invalid QDataStream data when serializing uninited QWebEngineHistory

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.5.4, 6.6.1, 6.7.0 FF
    • 6.5.2
    • WebEngine
    • None
    • f19aa5e34 (dev), ea1cb36bd (6.6), 4aaddd7fa (6.5)

    Description

      When serializing a QWebEngineHistory with no page fully loaded yet, with Qt 6.5, this results in a QDataStream claiming that it has one entry (which isn't actually the case). When then deserializing it, this results QtWebEngine to read past the end of the data stream.

      Possible culprit: Create initial NavigationEntry on FrameTree initialization (3237491) ยท Gerrit Code Review - though that landed in Chromium 98, yet this issue is not present in Qt 6.4.

      Reproducer:

      #include <QtWidgets/QApplication>
      #include <QtWebEngineWidgets/QWebEngineView>
      #include <QtWebEngineCore/QWebEngineHistory>
      #include <QtCore/QDataStream>
      #include <QtCore/QIODevice>
      
      int main(int argc, char *argv[]) {
          QApplication app{argc, argv};
          QWebEngineView view{};
      
          QByteArray data{};
          QDataStream stream1{&data, QIODeviceBase::ReadWrite};
          stream1 << *(view.history());
      
          // 0 (The data stream is operating normally.)
          qDebug() << stream1.status();
      
          // Qt 6.4.3: "00 00 00 04 00 00 00 00 ff ff ff ff"
          // Qt 6.5.2: "00 00 00 04 00 00 00 01 00 00 00 00"
          //            ^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^
          //            |           '-- count   '-- currentIndex
          //            '-- kHistoryStreamVersion
          qDebug() << data.toHex(' ');
      
          QDataStream stream2{data};
          stream2 >> *(view.history());
      
          // Qt 6.4.3: 0 (The data stream is operating normally.)
          // Qt 6.5.2: 1 (The data stream has read past the end of the data in the underlying device.)
          qDebug() << stream2.status();
      
          app.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mnegyokru Martin Negyokru
            the compiler Florian Bruhin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes