#39536 [Opn->Bgs]: magic_quotes_runtime breaks *binary* fread()
| From: | tony2001@php.net | Date: | Thu, 16 Nov 2006 16:56:04 +0000 |
| Subject: | #39536 [Opn->Bgs]: magic_quotes_runtime breaks *binary* fread() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105114@lists.php.net to get a copy of this message | ||
ID: 39536
Updated by: tony2001@php.net
Reported By: vpavlov at rila dot bg
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux (SLES 9)
PHP Version: 4.4.4
New Comment:
That's right, this is how magic_quotes_runtime are supposed to work.
And there is nothing wrong with the docs. Yes, "*from
any sort of external source* *including* databases and text files".
"Including" doesn't mean "only".
Previous Comments:
------------------------------------------------------------------------
[2006-11-16 16:30:26] vpavlov at rila dot bg
Description:
------------
using fread() on a file opened with fopen(..., "rb") will mis-read the
file when magic_quotes_runtime is ON. According to documentation:
If magic_quotes_runtime is enabled, most functions that return data
from any sort of external source including databases and ->text files<-
will have quotes escaped with a backslash.
Reproduce code:
---------------
// TEST 1
set_magic_quotes_runtime(1);
$fp = fopen("bahor.zip", "rb");
$contents = fread($fp, filesize("bahor.zip"));
echo strlen($contents) . "\n";
echo filesize("bahor.zip") . "\n";
fclose($fp);
// TEST 2
set_magic_quotes_runtime(0);
$fp = fopen("bahor.zip", "rb");
$contents = fread($fp, filesize("bahor.zip"));
echo strlen($contents) . "\n";
echo filesize("bahor.zip") . "\n";
fclose($fp);
Expected result:
----------------
When I say binary I do mean binary, regardless of what some option
claims. In the code above, the two sections should produce the same
results, the exact size of the zip file.
Actual result:
--------------
In test 1 the sizes reported by filesize("bahor.zip") and
strlen($contents) are different, due to the escaping which occurs
because of magic_quotes_runtime being On
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39536&edit=1