From:             fbeyer at clickhand dot de
Operating system: Windows XP
PHP version:      4CVS-2003-03-13 (stable)
PHP Bug Type:     Filesystem function related
Bug description:  Proplems with fread(), ftell() and fseek() and CRLF newlines

I have found this bug in 4.3.0, searched matching bug reports and they said
the bug is fixed in the latest stable CVS snap. I have downloaded and
installed today's latest version, the fix is mentioned in the news.txt,
but the bug is still there.

Here are my test files for a short reproducing script:

file test.txt:
(saved in dos format, ie. newlines are CRLF/\r\n):
------------------------------
This is a test file
in win32 / dos format
ie. lines end with CRLF
resp. \r\n
------------------------------

file test.php
------------------------------
<?php
$fp = fopen('test.txt', 'r');

$contents = fread($fp, 30);
fseek($fp, ftell($fp));
$contents .= fread($fp, 30);

echo $contents;

echo "\n\n";

var_dump(strpos($contents, "\r"));
?>
------------------------------

Output:
------------------------------
This is a test file
in win32 // dos format
ie. lines end wit

bool(false)
------------------------------

It can be seen that fseek() or ftell() don't work as expected: the '/'
character is read twice.

Furthermore, fread() doesn't return \r characters. I also have tested this
for fgetc() - \r is not read.

A strange thing is that this bug doesn't occurr in the newest php5/ze2
snapshot.
-- 
Edit bug report at http://bugs.php.net/?id=22682&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=22682&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=22682&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=22682&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=22682&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=22682&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=22682&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=22682&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=22682&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=22682&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=22682&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22682&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=22682&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=22682&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=22682&r=gnused

Reply via email to