|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9303 read() called with 'length' parameter reads until byte with ascii 10 or 13
Submitted: 2001-02-16 11:30 UTC Modified: 2001-06-02 21:26 UTC
From: yuri dot ismailov at era dot ericsson dot se Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.0.4pl1 OS: RedHat Linux
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:
Solve the problem:
38 + 43 = ?
Subscribe to this entry?

 [2001-02-16 11:30 UTC] yuri dot ismailov at era dot ericsson dot se
read($sockfd, $in, $length); If I read an arbitrary byte stream from the socket and it happens to be ascii code (decimal) 10 or 13, the length parameter does not have any affect on the number of bytes read from the socket. It stops at the first occurence of the "magic" byte. To continue reading you have to call read again. It does not look like so in the manual for the read() function. However, bytes following ascii \0 and \t are succesfully read.
Is this is the feature or a bug?
PHP compiled --with-apxs --enable-sockets


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-02 21:26 UTC]
Just use the 4th parameter (now documented, might not show
on the online manual yet) for read():

read($sockfd, $in, $length, PHP_READ_BINARY)


PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Nov 29 00:01:26 2023 UTC