|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-16 16:56 UTC] tony2001@php.net
[2006-11-17 07:59 UTC] vpavlov at rila dot bg
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 10:00:01 2025 UTC |
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