From: Christian Dickmann Date: Mon, 11 Nov 2002 01:23:24 +0000 (+0000) Subject: make cache (get/set) binary safe X-Git-Tag: php-4.3.0RC1~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c27f4f77cc45e6fcf61a4755b4ce4b2506fe8a0;p=php make cache (get/set) binary safe --- diff --git a/pear/PEAR/Remote.php b/pear/PEAR/Remote.php index 5662e9de01..0d1a11556c 100644 --- a/pear/PEAR/Remote.php +++ b/pear/PEAR/Remote.php @@ -62,10 +62,17 @@ class PEAR_Remote extends PEAR if (!file_exists($filename)) { return null; }; + + $fp = fopen($filename, "rb"); + if ($fp === null) { + return null; + } + $content = fread($fp, filesize($filename)); + fclose($fp); $result = array( 'age' => time() - filemtime($filename), 'lastChange' => filemtime($filename), - 'content' => unserialize(implode('', file($filename))), + 'content' => unserialize($content), ); return $result; } @@ -83,7 +90,7 @@ class PEAR_Remote extends PEAR } $filename = $cachedir.'/xmlrpc_cache_'.$id; - $fp = @fopen($filename, "w"); + $fp = @fopen($filename, "wb"); if ($fp !== null) { fwrite($fp, serialize($data)); fclose($fp);