|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11855 fgets returns truncated data
Submitted: 2001-07-03 10:12 UTC Modified: 2001-08-19 03:45 UTC
From: wiersig at glamus dot de Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.0.5 OS: Linux 2.2
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: wiersig at glamus dot de
New email:
PHP Version: OS:


 [2001-07-03 10:12 UTC] wiersig at glamus dot de
while reading chunks using fgets from a pdf-File, it occured that fgets seems to read data until a 0x0a occurs but returned the data until the first occurence of 0x00 only. Because of that, half of the data was lost.



will be read an returned correctly, the data containing "Hello" and the filepointer on the XYZ


will retrurn data containing "He" with the filepointer still on the XYZ

my code:
        while (!feof($fp)) {
            while ($i=strpos($pdf_line,"Needle",$i)) {
                 if ($i<4000) {
                 } else {
            if (strlen($pdf_line)>4000) {

we solved the problem by using fread() instead of fgets(), but felt you still might be interested.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-19 03:45 UTC]
Yes, fread() is binary safe, fgets() isn't. 
Not a bug.


PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Feb 20 13:01:28 2020 UTC