Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.6.0

Bug #19934 Infinite loop with stream wrapper passed as upload
Submitted: 2013-05-06 17:16 UTC
From: dmitriytrt Assigned: avb
Status: Closed Package: HTTP_Request2 (version 2.1.1)
PHP Version: 5.4.8 OS: Windows 7 x86
Roadmaps: (Not assigned)    
Subscription  


 [2013-05-06 17:16 UTC] dmitriytrt (Dmitriy Trt)
Description: ------------ The same file passed as a real path works fine, but fails into infinite loop when passed as a URI with underlying stream wrapper. In HTTP_Request2_MultipartBody::read() there is a wrong assumption that fread($this->_uploads[$pos]['fp'], $length) always returns $length bytes or reaches the end of file, it's not always true. When working with stream wrappers and reading with the $length larger than chunk size (8192) the fread() returns string of different size and leads to infinite loop in HTTP_Request2_Adapter_Socket::writeBody() where the actual data length is measured. PHP manual describes this situation with stream sockets (last condition that stops read): http://php.net/manual/en/function.fread.php I'm attaching the patch with quick fix.

Comments

 [2013-05-06 17:19 UTC] dmitriytrt (Dmitriy Trt)
 [2014-01-12 02:29 UTC] avb (Alexey Borzov)
-Status: Open +Status: Closed -Assigned To: +Assigned To: avb
Thanks, fixed in Git. https://github.com/pear/HTTP_Request2/commit/010bac1c0e8e2ad9f8847bfacbbe42faeb3f5583