BufferedSocket::setDataMode -> infinite loop

Bug #668548 reported by Crise / MW
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DC++
Fix Released
Undecided
Unassigned

Bug Description

if you call BufferedSocket::setDataMode with value that will be < left (ie. what is actually read from socket at once) it will go to an infinite loop, because when dataBytes have been read high will always end up 0 even if left > 0.

What you, probably, want to do is break after firing ModeChange... (line 267).

Granted with dcpp's current usage this doesn't never happen afaik... I stumbled on to this while adding support for chunked transfer encoding (where the chunk size is often less than the read buffer) to HttpConnection (to fix another would be bug, if server never sent Content-Length thus resulting setDataMode being called with -1, and http connection never properly completing).

Revision history for this message
iceman50 (bdcdevel) wrote :
Revision history for this message
Crise / MW (markuwil) wrote :

To quote the HTTP specification:
   All HTTP/1.1 applications that receive entities MUST accept the
   "chunked" transfer-coding (section 3.6), thus allowing this mechanism
   to be used for messages when the message length cannot be determined
   in advance.

Notably the patch also adds simple support for the POST request method. Changes in HttpDownload class were made to eliminate the unnecessary requirement of the completion function to have access to the original HttpDownload instance, in other words to have access to it outside of what was passed to the callback function, which in my opinion is counter-intuitive and restricting.

Also, as to changes pertaining the signaling of downloaded file type, if getMimeType() is not desired alternatively a listener that supplies the mime type could be used the old assumption, done with the listeners, of only downloading two kinds of files feels restrictive.

eMTee (realprogger)
Changed in dcplusplus:
status: New → Fix Committed
Revision history for this message
poy (poy) wrote :

Fixed in DC++ 0.810.

Changed in dcplusplus:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.