PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP_WebDAV_Server » Bug #6474

PUT always fails

Details

Submitted2006-01-12 12:26 UTC
Fromsl at yes-co dot nl
Assignedhholzgra
StatusDuplicate
PackageHTTP_WebDAV_Server
PHP Version5.1.1
OSLinux 2.6.8/Debian sarge
Roadmaps(Not assigned)

Comments

[2006-01-12 12:26 UTC] sl at yes-co dot nl

Description:
------------
When doing a PUT, the file is correctly written but the server always responds with 403 Forbidden. This is because the loop in Server.php (v 1.28 2005/04/05 22:51:09) on line 1156 fails. Only after fwrite returns 0 will feof return true.

Test script:
---------------
Request:
PUT /webdav/dav.php/templates4/file.doc HTTP/1.1
Accept-Language: nl, en-us;q=0.5
Connection: Keep-Alive
Content-Language: en-us
Content-Length: 4
Cookie: no_remote=1
Host: sarge.redbus.yes-co.nl
If: (<opaquelocktoken:0ea17a11-85a6-44ab-adc7-28b06a7e2da5>)
Translate: f
User-Agent: Microsoft Data Access Internet Publishing Provider DAV

vier

Expected result:
----------------
HTTP/1.1 204 No Content
Date: Thu, 12 Jan 2006 12:19:47 GMT
Server: Apache/1.3.33 Ben-SSL/1.55 (Debian GNU/Linux) PHP/5.1.1-1.dotdeb.2 DAV/1 .0.3
X-Powered-By: PHP/5.1.1-1.dotdeb.2
X-Dav-Powered-By: PHP class: VirtualWebDAV
X-WebDAV-Status: 204 No Content
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/plain; charset=iso-8859-1

Actual result:
--------------
Response:
HTTP/1.1 403 Forbidden
Date: Thu, 12 Jan 2006 12:17:59 GMT
Server: Apache/1.3.33 Ben-SSL/1.55 (Debian GNU/Linux) PHP/5.1.1-1.dotdeb.2 DAV/1 .0.3
X-Powered-By: PHP/5.1.1-1.dotdeb.2
X-Dav-Powered-By: PHP class: VirtualWebDAV
X-WebDAV-Status: 403 Forbidden
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain; charset=iso-8859-1

0

[2006-01-15 21:32 UTC] sl at yes-co dot nl

The code is:

while (!feof($options["stream"])) {
if (!fwrite($stream, fread($options["stream"], 4096))) {
$stat = "403 Forbidden";
break;
}

If fwrite() returns 0 the code in the if statement will be executed. fwrite() will return 0 at the end of the stream, but before feof() returns true. The condition should use !== to test for false, but not for 0.