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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kraghuba at in dot ibm dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 06:01:38 2025 UTC