#18984 [Opn->Fbk]: fread() add slashes on the content randomly
| From: | sander@php.net | Date: | Tue, 20 Aug 2002 13:10:33 +0000 |
| Subject: | #18984 [Opn->Fbk]: fread() add slashes on the content randomly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-17292@lists.php.net to get a copy of this message | ||
ID: 18984
Updated by: sander@php.net
Reported By: dams@php.net
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
Operating System: Linux debian 2
PHP Version: 4.1.2
New Comment:
Are you sure this isn't caused by one of the magic_quotes_* ini
settings?
Previous Comments:
------------------------------------------------------------------------
[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