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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
1 + 26 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 17:01:30 2024 UTC