PHP 4.0 Bug #6068: fread stops

From: Date: Thu, 10 Aug 2000 10:17:54 +0000
Subject: PHP 4.0 Bug #6068: fread stops
Groups: php.dev 
Request: Send a blank email to php-dev+get-28327@lists.php.net to get a copy of this message
From: richard@zend.com Operating system: Win98 PHP version: 4.0.1pl2 PHP Bug Type: Misbehaving function Bug description: fread stops <HTML><BODY> <?php set_time_limit(0); clearstatcache(); $input = fopen('C:/phpcvs/phpcvs.tar.gz', 'r') or die('could not open input'); $output = fopen('A:/phpcvs.tar.gz.1', 'w') or die('could not open ouput'); $start = 0; $chunk = 100; $length = 1024*1024; fseek($input, $start); $current = $start; echo "Filesize is ", filesize('C:/phpcvs/phpcvs.tar.gz'), "<BR>\n"; while ($current < $length && !feof($input)){ $data = fread($input, $chunk); $wrote = fwrite($output, $data, $chunk); $current += $wrote; echo $current, "<BR>\n"; flush(); } $count = 330; (fseek($input, 330)+1) or die ("Error fseeking 330<BR>\n"); while (!feof($input) && $count < 350){ $char = fgetc($input); echo ftell($input), " '$char' (", ord($char), ")<BR>\n"; $count++; } fclose($input); fclose($output); echo "<BR>Done."; ?> </BODY></HTML> OUTPUT: Filesize is 2233724 100 200 300 337 331 '' (0) 332 'S' (83) 333 ';' (59) 334 'N' (78) 335 ';' (59) 336 'õ' (245) 337 '|' (124) 338 '‰' (137) 842 'È' (200) 4427 '' (16) 4428 'x' (120) 4429 'F' (70) 4430 '^' (94) 4431 'e' (101) 4432 'š' (154) 4433 'ë' (235) 4434 'ï' (239) 4435 '' (15) 4436 '7' (55) 4437 'b' (98) Done. Expected Output: 1.4 Megs copied 100 bytes at a time, and something sensible from ftell after byte 338... filesize() knows how big the file is, but fread, feof, fgetc, etc are all convinced it's only 337 bytes long... But char 337 and 338 are not even end of string. 331 is, but it's not even dying there, which would almost make sense, except fread and fgetc are supposed to be binary safe... The mod_php4.dll from that geocities guy is in there... Relevant? One wouldn't think so... The php.exe seems to work just fine, so I guess it is though, unless it's in some other DLL that gets involved with Apache and PHP somehow, but not with PHP.exe.

« previous php.dev (#28327) next »