php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13086 fread design flaw
Submitted: 2001-08-31 19:24 UTC Modified: 2001-08-31 19:28 UTC
From: clarkbattle at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: win2k
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: clarkbattle at hotmail dot com
New email:
PHP Version: OS:

 

 [2001-08-31 19:24 UTC] clarkbattle at hotmail dot com
This is more of a design flaw than a bug.  In C the fread() function returns the number of bytes read.  In php it returns the string read.  The C version is better.  If you are reading binary data from a remote HTTP source and you need to know how much data you have read it is impossible with the PHP version.  You cant read in a chunk then do a strlen() on the chunk because its binary and may contain null chars.  read() seems to have the right interface but its experimental and only for sockets.  

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-31 19:28 UTC] rasmus@php.net
You mistakenly assume that the PHP strlen() function will stop counting at a NUL.  That is not the case.  It will correctly tell you the number of bytes, including NULs in a string.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 21:01:30 2025 UTC