php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22546 fread (maybe in connection with fseek) do not read "length" bytes
Submitted: 2003-03-05 04:10 UTC Modified: 2003-03-05 08:17 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: 4u at direct-netware dot de Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.1 OS: WinNT
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: 4u at direct-netware dot de
New email:
PHP Version: OS:

 

 [2003-03-05 04:10 UTC] 4u at direct-netware dot de
>>> Description:

fread (maybe in connection with fseek) do not read "length" bytes - example:

@fseek (Resource id #113,75);
@fread (Resource id #113,4633);
Read bytes reported by strlen: 5
@fseek (Resource id #113,4750);
@fread (Resource id #113,90);
Read bytes reported by strlen: 90
@fseek (Resource id #113,4881);
@fread (Resource id #113,5656);
Read bytes reported by strlen: 169
@fseek (Resource id #113,10593);
@fread (Resource id #113,5635);
Read bytes reported by strlen: 104
@fseek (Resource id #113,16282);
@fread (Resource id #113,1277);
Read bytes reported by strlen: 1277
@fseek (Resource id #113,17601);
@fread (Resource id #113,1415);
Read bytes reported by strlen: 283
@fseek (Resource id #113,19083);
@fread (Resource id #113,309);
Read bytes reported by strlen: 167

> Example part of the script:
@fseek ($zipp,$direct_tempdata_2array['zip_filebegin']);
$direct_tempdata_4string = @fread ($zipp,$direct_tempdata_2array['zip_filesize_compressed']);

>>> Modules:

Seems to be not required for this bug report

>>> Setup data:

Windows XP
PHP 4.3.1 and PHP 4.3.2-dev
Apache 2.0.44
MySQL 4.0.11-gamma
Administrative rights: yes

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-05 04:20 UTC] 4u at direct-netware dot de
Looking at the bug, it is maybe causing the following reported bug because the size for inflating is wrong:
http://bugs.php.net/bug.php?id=22471

I recomment to resolve this bug and wait for further information regarding bug #22471
 [2003-03-05 04:54 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

Should already be fixed in the stable snapshot.
 [2003-03-05 05:08 UTC] 4u at direct-netware dot de
I will check it with the next stable win32-build and reopen this report if required (6h to go until the next build will be available)
 [2003-03-05 06:20 UTC] wez@php.net
This was fixed last week; any current snapshot should contain the fix.
 [2003-03-05 06:25 UTC] 4u at direct-netware dot de
I'm sorry, but then the bug isn't (completly?) removed - used snapshot resulting fread-error: php4-win32-STABLE-200303050930
 [2003-03-05 06:48 UTC] sniper@php.net
Just replace every existing php4ts.dll with the new one from the snapshot package..and make sure nothing is running when you do this.


 [2003-03-05 07:54 UTC] 4u at direct-netware dot de
I know how to install PHP using a ZIP-file...
1,22 MB (1.286.144 Bytes) - Is this the right dll? (At least this is the dll in the snapshot I downloaded - Last edited today)

The error still exists with the dll, mentioned above!
 [2003-03-05 08:17 UTC] 4u at direct-netware dot de
Strange things happening here - I will check it before getting on your nerves again ;)
 [2003-08-02 05:56 UTC] diz at ysagoon dot com
I don't know if this is related, but I think so. Please tell me if I should better submit this as a new bug.

The fseek teleports my file pointer to some strange places. I'm using Win2K (NT5 SP4) with administrative rights and I'm running EasyPhp 1.6.0.0 that contains PHP 4.2.0. But the same script works on Debian GNU/Linux 2.2.20 with PHP 4.1.2!

Here's my example script (note that none of the two fseek methods work):

function getChar($fp, &$c)
{
    $c=fgetc($fp);
    if(feof($fp))
        return false;
    return true;
}

$fp=fopen('parseTest.txt','r');
while(true)
{
    $c=fgetc($fp);
    if(feof($fp))
        break;
    echo("$c");

    //fseek($fp, -1, SEEK_CUR);
    fseek($fp, ftell($fp)-1);

    $c=fgetc($fp);
    if(feof($fp))
        break;
    echo("$c");
}
fclose($fp);
echo('<EOF>');

The file that I read contains just this:
Hello World!

The correct output on Debian GNU/Linux 2.2.20 with PHP 4.1.2:
hheelllloo  wwoorrlldd!!

<EOF>

The problematic output on Win2k with PHP 4.2.0:
h<EOF>

Ok that's it. Thank you for your support! :)

Gabriel
 [2003-08-02 20:43 UTC] diz at ysagoon dot com
Ok, well the problem I spoke about is solved with PHP 4.3.2.

Gabriel
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC