#18984 [Bgs]: fread() add slashes on the content randomly
| From: | nohn@php.net | Date: | Tue, 20 Aug 2002 13:16:46 +0000 |
| Subject: | #18984 [Bgs]: fread() add slashes on the content randomly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-17294@lists.php.net to get a copy of this message | ||
ID: 18984
Updated by: nohn@php.net
Reported By: dams@php.net
Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux debian 2
PHP Version: 4.1.2
New Comment:
Verified on these systems as working:
awaited : 1170573
read : 1170573
Compaq Tru64 (php 4.3-dev, php 4.2-dev)
SuSE Linux (php 4.3-dev, php 4.2.2, php 4.0.6)
Magic quotes is off on every system:
Previous Comments:
------------------------------------------------------------------------
[2002-08-20 09:13:19] nohn@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2002-08-20 09:10:33] sander@php.net
Are you sure this isn't caused by one of the magic_quotes_* ini
settings?
------------------------------------------------------------------------
[2002-08-20 08:58:44] dams@php.net
Hi,
on my PHP 4.1.2, fread() adds randomly a addslashes() when
reading a binary file. Here is the code :
<?php
$fp=fopen($fichier,"r");
$attendu = filesize($fichier);
$attachmentorig=fread($fp,$attendu);
$lu = strlen($attachmentorig);
print "awaited : $attendu<BR>\n";
print "read : $lu<BR>\n";
fclose($fp);
?>
basically, it reads the file (I used any JPG picture as
test), and then it happens sometimes (rather unusually)
that the read size is about 10% bigger than the original
file size.
The increase in size is always the same, when it happens.
With further testing, I finally managed to find that, if
the returned string is bigger than the original file size,
then applying stripslashes() will solve the trouble.
I tested this also on 4.2.2 (macosx) and fresh 4.3.0-dev,
and no trouble seems to be reproducable, so it may be a
solved trouble. It may be a 4.1.2 specific trouble.
I hope this post will help anyone facing this trouble, or
point some real bug.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18984&edit=1