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

Compressed HTTP reply uncompression fails if buffer fills exactly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.4
    • 4.6.0, 4.6.1, 4.6.2, 4.6.3, 4.7.0
    • Network
    • None
    • This is reproduced in Windows.
    • cc504be6500911d9109f513a60c8116cacb39fe4

    Description

      Method QHttpNetworkReplyPrivate::gunzipBodyPartially returns error code incorrectly for example in the following scenario:

      Entering the do-while loop with following values:

      • inflateStrm.avail_in = 15000
      • inflateStrm.avail_out = CHUNK (16384)

      zlib's inflate call uncompresses the 15000 input bytes to exactly 16384 bytes thus filling the buffer.

      The while condition (inflateStrm.avail_out == 0) in this case so new do-loop is started with inflateStrm.avail_in = 0. Now when inflate is called it returns Z_BUF_ERROR because there is no input data.

      This causes inflate to fail and the method report error to caller which results dropped connection. Thus it seems that compressed http gets might fail anytime!

      My fix suggestion is to change the while condition check to this:

      } while (inflateStrm.avail_out == 0 && inflateStrm.avail_in > 0)

      Thus when the buffer fills exactly and there is no more input we just return with OK result.

      More information about this in http://www.zlib.net/zlib_how.html.

      Attachments

        Issue Links

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

          Activity

            People

              phartman Peter Hartmann (closed Nokia identity) (Inactive)
              jsn73 Juha Nuutinen
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes