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

QFile::read/QIODevice::read crashes on big files

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.4.0 Beta, 5.4.0
    • 4.8.5, 4.8.6, 5.2.1, 5.3.0, 5.3.1
    • Core: I/O
    • None
    • All versions

    Description

      QIODevice::read(char*,qint64 maxLen) crashes on large Files if maxlen > qin32_MAX in QIODevicePrivateLinearBuffer::read -> wrong cast of maxlen to int

      -------------------------------------------------------------------

      QFile tFile("c:/bigfile.bin");
      char* tData=new char[3000000000];
      //tFile.size() = 2227814416
      if(tFile.open(QIODevice::ReadOnly))

      { tFile.read(tData,tFile.size()); //-> crash }


      qint64 QIODevice::read(char *data, qint64 maxSize)
      .
      .
      .
      do {
      // Try reading from the buffer.
      int lastReadChunkSize = d->buffer.read(data, maxSize);


      QIODevicePrivateLinearBuffer
      .
      .
      .
      int read(char* target, int size)

      { !!!!!!!!!!!! size and r is negativ on int cast from int64 > int32 and memcpy crashes int r = qMin(size, len); memcpy(target, first, r); len -= r; first += r; return r; }

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            bratyy brat
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes