php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42057 fwrite() writes data into file when length is given as a negative value
Submitted: 2007-07-21 07:33 UTC Modified: 2008-02-04 18:47 UTC
From: kraghuba at in dot ibm dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 6CVS-2007-07-21 (CVS) OS: RHEL 5
Private report: No CVE-ID: None
 [2007-07-21 07:33 UTC] kraghuba at in dot ibm dot com
Description:
------------
fwrite() writes given data to the file when length paramenter is given as a negative value.

This is only applicable to php6.


Reproduce code:
---------------
<?php
 $fp = fopen("test.dat", "w");
 $data = "data";
 var_dump(fwrite($fp, $data, -10) );
 fclose($fp);
 var_dump(readfile("test.dat") );
 unlink("test.dat");
?>


Expected result:
----------------
int(0)
int(0)


Actual result:
--------------
int(4)
dataint(4)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-04 18:47 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 12:01:30 2024 UTC