]> granicus.if.org Git - php/commitdiff
Remove binary casts from PHAR's default stub
authorPedro Magalhães <mail@pmmaga.net>
Sun, 6 Nov 2016 22:11:57 +0000 (23:11 +0100)
committerJoe Watkins <krakjoe@php.net>
Wed, 9 Nov 2016 03:24:40 +0000 (03:24 +0000)
18 files changed:
ext/phar/stub.h
ext/phar/tests/cache_list/copyonwrite11.phar.phpt
ext/phar/tests/cache_list/files/nophar.phar
ext/phar/tests/cache_list/files/openssl.phar
ext/phar/tests/files/include_path2.phar
ext/phar/tests/files/nophar.phar
ext/phar/tests/files/openssl.phar
ext/phar/tests/phar_commitwrite.phpt
ext/phar/tests/phar_convert_repeated.phpt
ext/phar/tests/phar_create_in_cwd.phpt
ext/phar/tests/phar_createdefaultstub.phpt
ext/phar/tests/phar_offset_check.phpt
ext/phar/tests/phar_setdefaultstub.phpt
ext/phar/tests/tar/phar_convert_phar.phpt
ext/phar/tests/tar/phar_convert_phar2.phpt
ext/phar/tests/tar/phar_convert_phar3.phpt
ext/phar/tests/tar/phar_convert_phar4.phpt
ext/phar/tests/zip/phar_convert_phar.phpt

index 139ac5da5718d7325abdd011bab0fe0ea555969c..2ae2ed8b0860351f6d8023cc7f16331eee63affb 100644 (file)
@@ -24,11 +24,10 @@ static inline zend_string* phar_get_stub(const char *index_php, const char *web,
        static const char newstub1_0[] = "';\n\nif (in_array('phar', stream_get_wrappers()) && class_exists('Phar', 0)) {\nPhar::interceptFileFuncs();\nset_include_path('phar://' . __FILE__ . PATH_SEPARATOR . get_include_path());\nPhar::webPhar(null, $web);\ninclude 'phar://' . __FILE__ . '/' . Extract_Phar::START;\nreturn;\n}\n\nif (@(isset($_SERVER['REQUEST_URI']) && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'POST'))) {\nExtract_Phar::go(true);\n$mimes = array(\n'phps' => 2,\n'c' => 'text/plain',\n'cc' => 'text/plain',\n'cpp' => 'text/plain',\n'c++' => 'text/plain',\n'dtd' => 'text/plain',\n'h' => 'text/plain',\n'log' => 'text/plain',\n'rng' => 'text/plain',\n'txt' => 'text/plain',\n'xsd' => 'text/plain',\n'php' => 1,\n'inc' => 1,\n'avi' => 'video/avi',\n'bmp' => 'image/bmp',\n'css' => 'text/css',\n'gif' => 'image/gif',\n'htm' => 'text/html',\n'html' => 'text/html',\n'htmls' => 'text/html',\n'ico' => 'image/x-ico',\n'jpe' => 'image/jpeg',\n'jpg' => 'image/jpeg',\n'jpeg' => 'image/jpeg',\n'js' => 'application/x-javascript',\n'midi' => 'audio/midi',\n'mid' => 'audio/midi',\n'mod' => 'audio/mod',\n'mov' => 'movie/quicktime',\n'mp3' => 'audio/mp3',\n'mpg' => 'video/mpeg',\n'mpeg' => 'video/mpeg',\n'pdf' => 'application/pdf',\n'png' => 'image/png',\n'swf' => 'application/shockwave-flash',\n'tif' => 'image/tiff',\n'tiff' => 'image/tiff',\n'wav' => 'audio/wav',\n'xbm' => 'image/xbm',\n'xml' => 'text/xml',\n);\n\nheader(\"Cache-Control: no-cache, must-revalidate\");\nheader(\"Pragma: no-cache\");\n\n$basename = basename(__FILE__);\nif (!strpos($_SERVER['REQUEST_URI'], $basename)) {\nchdir(Extract_Phar::$temp);\ninclude $web;\nreturn;\n}\n$pt = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $basename) + strlen($basename));\nif (!$pt || $pt == '/') {\n$pt = $web;\nheader('HTTP/1.1 301 Moved Permanently');\nheader('Location: ' . $_SERVER['REQUEST_URI'] . '/' . $pt);\nexit;\n}\n$a = realpath(Extract_Phar::$temp . DIRECTORY_SEPARATOR . $pt);\nif (!$a || strlen(dirname($a)) < strlen(";
        static const char newstub1_1[] = "Extract_Phar::$temp)) {\nheader('HTTP/1.0 404 Not Found');\necho \"<html>\\n <head>\\n  <title>File Not Found<title>\\n </head>\\n <body>\\n  <h1>404 - File \", $pt, \" Not Found</h1>\\n </body>\\n</html>\";\nexit;\n}\n$b = pathinfo($a);\nif (!isset($b['extension'])) {\nheader('Content-Type: text/plain');\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\nif (isset($mimes[$b['extension']])) {\nif ($mimes[$b['extension']] === 1) {\ninclude $a;\nexit;\n}\nif ($mimes[$b['extension']] === 2) {\nhighlight_file($a);\nexit;\n}\nheader('Content-Type: ' .$mimes[$b['extension']]);\nheader('Content-Length: ' . filesize($a));\nreadfile($a);\nexit;\n}\n}\n\nclass Extract_Phar\n{\nstatic $temp;\nstatic $origdir;\nconst GZ = 0x1000;\nconst BZ2 = 0x2000;\nconst MASK = 0x3000;\nconst START = '";
        static const char newstub2[] = "';\nconst LEN = ";
-       static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = (binary)fread($fp, 4));\n$m = (binary)'';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = (binary)fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::ST";
-       static const char newstub3_1[] = "ART;\n}\n}\n\nstatic function tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len = unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n   $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32((binary)$data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPIL";
-       static const char newstub3_2[] = "ER(); ?>";
+       static const char newstub3_0[] = ";\n\nstatic function go($return = false)\n{\n$fp = fopen(__FILE__, 'rb');\nfseek($fp, self::LEN);\n$L = unpack('V', $a = fread($fp, 4));\n$m = '';\n\ndo {\n$read = 8192;\nif ($L[1] - strlen($m) < 8192) {\n$read = $L[1] - strlen($m);\n}\n$last = fread($fp, $read);\n$m .= $last;\n} while (strlen($last) && strlen($m) < $L[1]);\n\nif (strlen($m) < $L[1]) {\ndie('ERROR: manifest length read was \"' .\nstrlen($m) .'\" should be \"' .\n$L[1] . '\"');\n}\n\n$info = self::_unpack($m);\n$f = $info['c'];\n\nif ($f & self::GZ) {\nif (!function_exists('gzinflate')) {\ndie('Error: zlib extension is not enabled -' .\n' gzinflate() function needed for zlib-compressed .phars');\n}\n}\n\nif ($f & self::BZ2) {\nif (!function_exists('bzdecompress')) {\ndie('Error: bzip2 extension is not enabled -' .\n' bzdecompress() function needed for bz2-compressed .phars');\n}\n}\n\n$temp = self::tmpdir();\n\nif (!$temp || !is_writable($temp)) {\n$sessionpath = session_save_path();\nif (strpos ($sessionpath, \";\") !== false)\n$sessionpath = substr ($sessionpath, strpos ($sessionpath, \";\")+1);\nif (!file_exists($sessionpath) || !is_dir($sessionpath)) {\ndie('Could not locate temporary directory to extract phar');\n}\n$temp = $sessionpath;\n}\n\n$temp .= '/pharextract/'.basename(__FILE__, '.phar');\nself::$temp = $temp;\nself::$origdir = getcwd();\n@mkdir($temp, 0777, true);\n$temp = realpath($temp);\n\nif (!file_exists($temp . DIRECTORY_SEPARATOR . md5_file(__FILE__))) {\nself::_removeTmpFiles($temp, getcwd());\n@mkdir($temp, 0777, true);\n@file_put_contents($temp . '/' . md5_file(__FILE__), '');\n\nforeach ($info['m'] as $path => $file) {\n$a = !file_exists(dirname($temp . '/' . $path));\n@mkdir(dirname($temp . '/' . $path), 0777, true);\nclearstatcache();\n\nif ($path[strlen($path) - 1] == '/') {\n@mkdir($temp . '/' . $path, 0777);\n} else {\nfile_put_contents($temp . '/' . $path, self::extractFile($path, $file, $fp));\n@chmod($temp . '/' . $path, 0666);\n}\n}\n}\n\nchdir($temp);\n\nif (!$return) {\ninclude self::START;\n}\n}\n\nstatic fun";
+       static const char newstub3_1[] = "ction tmpdir()\n{\nif (strpos(PHP_OS, 'WIN') !== false) {\nif ($var = getenv('TMP') ? getenv('TMP') : getenv('TEMP')) {\nreturn $var;\n}\nif (is_dir('/temp') || mkdir('/temp')) {\nreturn realpath('/temp');\n}\nreturn false;\n}\nif ($var = getenv('TMPDIR')) {\nreturn $var;\n}\nreturn realpath('/tmp');\n}\n\nstatic function _unpack($m)\n{\n$info = unpack('V', substr($m, 0, 4));\n $l = unpack('V', substr($m, 10, 4));\n$m = substr($m, 14 + $l[1]);\n$s = unpack('V', substr($m, 0, 4));\n$o = 0;\n$start = 4 + $s[1];\n$ret['c'] = 0;\n\nfor ($i = 0; $i < $info[1]; $i++) {\n $len = unpack('V', substr($m, $start, 4));\n$start += 4;\n $savepath = substr($m, $start, $len[1]);\n$start += $len[1];\n   $ret['m'][$savepath] = array_values(unpack('Va/Vb/Vc/Vd/Ve/Vf', substr($m, $start, 24)));\n$ret['m'][$savepath][3] = sprintf('%u', $ret['m'][$savepath][3]\n& 0xffffffff);\n$ret['m'][$savepath][7] = $o;\n$o += $ret['m'][$savepath][2];\n$start += 24 + $ret['m'][$savepath][5];\n$ret['c'] |= $ret['m'][$savepath][4] & self::MASK;\n}\nreturn $ret;\n}\n\nstatic function extractFile($path, $entry, $fp)\n{\n$data = '';\n$c = $entry[2];\n\nwhile ($c) {\nif ($c < 8192) {\n$data .= @fread($fp, $c);\n$c = 0;\n} else {\n$c -= 8192;\n$data .= @fread($fp, 8192);\n}\n}\n\nif ($entry[4] & self::GZ) {\n$data = gzinflate($data);\n} elseif ($entry[4] & self::BZ2) {\n$data = bzdecompress($data);\n}\n\nif (strlen($data) != $entry[0]) {\ndie(\"Invalid internal .phar file (size error \" . strlen($data) . \" != \" .\n$stat[7] . \")\");\n}\n\nif ($entry[3] != sprintf(\"%u\", crc32($data) & 0xffffffff)) {\ndie(\"Invalid internal .phar file (checksum error)\");\n}\n\nreturn $data;\n}\n\nstatic function _removeTmpFiles($temp, $origdir)\n{\nchdir($temp);\n\nforeach (glob('*') as $f) {\nif (file_exists($f)) {\nis_dir($f) ? @rmdir($f) : @unlink($f);\nif (file_exists($f) && is_dir($f)) {\nself::_removeTmpFiles($f, getcwd());\n}\n}\n}\n\n@rmdir($temp);\nclearstatcache();\nchdir($origdir);\n}\n}\n\nExtract_Phar::go();\n__HALT_COMPILER(); ?>";
 
-       static const int newstub_len = 6665;
+       static const int newstub_len = 6633;
 
-       return strpprintf(name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1, newstub3_2);
+       return strpprintf(name_len + web_len + newstub_len, "%s%s%s%s%s%s%d%s%s", newstub0, web, newstub1_0, newstub1_1, index_php, newstub2, name_len + web_len + newstub_len, newstub3_0, newstub3_1);
 }
index 65388163dc54159d546386e1ba3b0ad4d02b032b..bf7367c8b6b876114b19af6b280e5194851c1561 100644 (file)
@@ -18,5 +18,5 @@ echo strlen($p2->getStub()),"\n";
 echo "ok\n";
 __HALT_COMPILER(); ?>
 "
-6685
+6653
 ok
\ No newline at end of file
index 4eb3083c924aa6c5ca06071d6607ae6f5dd8c59e..e6bf37a8458086fd96b705df6c984e7c2768bdf8 100644 (file)
Binary files a/ext/phar/tests/cache_list/files/nophar.phar and b/ext/phar/tests/cache_list/files/nophar.phar differ
index f3864d7faacb9b6a50215f8f0b9513839ef71fd5..1e6f5e2f7e69597f434dbb2b0fffdee7374ac647 100644 (file)
Binary files a/ext/phar/tests/cache_list/files/openssl.phar and b/ext/phar/tests/cache_list/files/openssl.phar differ
index bb0ba79c84e0017bf8497cc4354f67ee6b98e354..190b60e9a81abdbfbe04e52a9ade806da525f4d9 100644 (file)
Binary files a/ext/phar/tests/files/include_path2.phar and b/ext/phar/tests/files/include_path2.phar differ
index 4eb3083c924aa6c5ca06071d6607ae6f5dd8c59e..e9d3fef414d27d1d62b6a1032ba0c6ce0aae7135 100644 (file)
Binary files a/ext/phar/tests/files/nophar.phar and b/ext/phar/tests/files/nophar.phar differ
index f3864d7faacb9b6a50215f8f0b9513839ef71fd5..1e6f5e2f7e69597f434dbb2b0fffdee7374ac647 100644 (file)
Binary files a/ext/phar/tests/files/openssl.phar and b/ext/phar/tests/files/openssl.phar differ
index 36d473e5c21a128ae8490e7c5cb9c011fab00859..63878355b04b401eb3dbc28cb16201f958b0dd57 100644 (file)
@@ -29,7 +29,7 @@ unlink(dirname(__FILE__) . '/brandnewphar.phar');
 __HALT_COMPILER();
 ?>
 --EXPECT--
-int(6683)
+int(6651)
 string(200) "<?php
 function __autoload($class)
 {
index e4b1fe41d770c831253934f5ce9fd7fd13098e42..b2ef195ea7868673585afc07f12d937af0795612 100644 (file)
@@ -123,7 +123,7 @@ NULL
 bool(true)
 bool(false)
 bool(false)
-int(6683)
+int(6651)
 NULL
 ================= convertToZip() =====================
 bool(false)
index 4b0e6594fb14d4baf30a21c4f76941507991708b..83de7bed289833967a25e4e3daa0e4febe64ee2e 100644 (file)
@@ -32,7 +32,7 @@ __HALT_COMPILER();
 unlink(dirname(__FILE__) . '/brandnewphar.phar');
 ?>
 --EXPECT--
-int(6683)
+int(6651)
 string(200) "<?php
 function __autoload($class)
 {
index abc9ad8e5b1570dbb8d173961098ebc9bdff5f38..a8648dc311a3258ceeeb7f798a49e2e059ca1b1f 100644 (file)
@@ -34,7 +34,7 @@ echo $e->getMessage() . "\n";
 ?>
 ===DONE===
 --EXPECT--
-string(6683) "<?php
+string(6651) "<?php
 
 $web = 'index.php';
 
@@ -144,21 +144,21 @@ const GZ = 0x1000;
 const BZ2 = 0x2000;
 const MASK = 0x3000;
 const START = 'index.php';
-const LEN = 6685;
+const LEN = 6653;
 
 static function go($return = false)
 {
 $fp = fopen(__FILE__, 'rb');
 fseek($fp, self::LEN);
-$L = unpack('V', $a = (binary)fread($fp, 4));
-$m = (binary)'';
+$L = unpack('V', $a = fread($fp, 4));
+$m = '';
 
 do {
 $read = 8192;
 if ($L[1] - strlen($m) < 8192) {
 $read = $L[1] - strlen($m);
 }
-$last = (binary)fread($fp, $read);
+$last = fread($fp, $read);
 $m .= $last;
 } while (strlen($last) && strlen($m) < $L[1]);
 
@@ -298,7 +298,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
 $stat[7] . ")");
 }
 
-if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
 die("Invalid internal .phar file (checksum error)");
 }
 
@@ -328,7 +328,7 @@ Extract_Phar::go();
 __HALT_COMPILER(); ?>"
 ============================================================================
 ============================================================================
-string(6694) "<?php
+string(6662) "<?php
 
 $web = 'index.php';
 
@@ -438,21 +438,21 @@ const GZ = 0x1000;
 const BZ2 = 0x2000;
 const MASK = 0x3000;
 const START = 'my/custom/thingy.php';
-const LEN = 6696;
+const LEN = 6664;
 
 static function go($return = false)
 {
 $fp = fopen(__FILE__, 'rb');
 fseek($fp, self::LEN);
-$L = unpack('V', $a = (binary)fread($fp, 4));
-$m = (binary)'';
+$L = unpack('V', $a = fread($fp, 4));
+$m = '';
 
 do {
 $read = 8192;
 if ($L[1] - strlen($m) < 8192) {
 $read = $L[1] - strlen($m);
 }
-$last = (binary)fread($fp, $read);
+$last = fread($fp, $read);
 $m .= $last;
 } while (strlen($last) && strlen($m) < $L[1]);
 
@@ -592,7 +592,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
 $stat[7] . ")");
 }
 
-if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
 die("Invalid internal .phar file (checksum error)");
 }
 
@@ -622,7 +622,7 @@ Extract_Phar::go();
 __HALT_COMPILER(); ?>"
 ============================================================================
 ============================================================================
-int(7074)
+int(7042)
 ============================================================================
 ============================================================================
 Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
@@ -630,7 +630,7 @@ Illegal filename passed in for stub creation, was 401 characters long, and only
 ============================================================================
 ============================================================================
 ============================================================================
-string(6696) "<?php
+string(6664) "<?php
 
 $web = 'the/web.php';
 
@@ -740,21 +740,21 @@ const GZ = 0x1000;
 const BZ2 = 0x2000;
 const MASK = 0x3000;
 const START = 'my/custom/thingy.php';
-const LEN = 6698;
+const LEN = 6666;
 
 static function go($return = false)
 {
 $fp = fopen(__FILE__, 'rb');
 fseek($fp, self::LEN);
-$L = unpack('V', $a = (binary)fread($fp, 4));
-$m = (binary)'';
+$L = unpack('V', $a = fread($fp, 4));
+$m = '';
 
 do {
 $read = 8192;
 if ($L[1] - strlen($m) < 8192) {
 $read = $L[1] - strlen($m);
 }
-$last = (binary)fread($fp, $read);
+$last = fread($fp, $read);
 $m .= $last;
 } while (strlen($last) && strlen($m) < $L[1]);
 
@@ -894,7 +894,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
 $stat[7] . ")");
 }
 
-if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
 die("Invalid internal .phar file (checksum error)");
 }
 
@@ -924,6 +924,6 @@ Extract_Phar::go();
 __HALT_COMPILER(); ?>"
 ============================================================================
 ============================================================================
-int(7074)
+int(7042)
 Illegal web filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
 ===DONE===
index fe12534915d07e2fde28814b75d9c03125f7a96c..a4a65e9e0411e3162d7aa91238b9eba69a096fd3 100644 (file)
@@ -70,8 +70,8 @@ var_dump($phar->getAlias());
 Entry .phar/stub.php does not exist
 Entry .phar/alias.txt does not exist
 Cannot set stub ".phar/stub.php" directly in phar "%sphar_offset_check.phar.php", use setStub
-int(6685)
-int(6685)
+int(6653)
+int(6653)
 Cannot set alias ".phar/alias.txt" directly in phar "%sphar_offset_check.phar.php", use setAlias
 string(5) "susan"
 string(5) "susan"
index 434e6471f58767f9265a9f9859659bfe2e52930e..a36c005eac3e1155ed25b1a217f9668e78559707 100644 (file)
@@ -54,7 +54,7 @@ try {
 unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
 ?>
 --EXPECT--
-string(6685) "<?php
+string(6653) "<?php
 
 $web = 'index.php';
 
@@ -164,21 +164,21 @@ const GZ = 0x1000;
 const BZ2 = 0x2000;
 const MASK = 0x3000;
 const START = 'index.php';
-const LEN = 6685;
+const LEN = 6653;
 
 static function go($return = false)
 {
 $fp = fopen(__FILE__, 'rb');
 fseek($fp, self::LEN);
-$L = unpack('V', $a = (binary)fread($fp, 4));
-$m = (binary)'';
+$L = unpack('V', $a = fread($fp, 4));
+$m = '';
 
 do {
 $read = 8192;
 if ($L[1] - strlen($m) < 8192) {
 $read = $L[1] - strlen($m);
 }
-$last = (binary)fread($fp, $read);
+$last = fread($fp, $read);
 $m .= $last;
 } while (strlen($last) && strlen($m) < $L[1]);
 
@@ -318,7 +318,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
 $stat[7] . ")");
 }
 
-if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
 die("Invalid internal .phar file (checksum error)");
 }
 
@@ -349,7 +349,7 @@ __HALT_COMPILER(); ?>
 "
 ============================================================================
 ============================================================================
-string(6696) "<?php
+string(6664) "<?php
 
 $web = 'index.php';
 
@@ -459,21 +459,21 @@ const GZ = 0x1000;
 const BZ2 = 0x2000;
 const MASK = 0x3000;
 const START = 'my/custom/thingy.php';
-const LEN = 6696;
+const LEN = 6664;
 
 static function go($return = false)
 {
 $fp = fopen(__FILE__, 'rb');
 fseek($fp, self::LEN);
-$L = unpack('V', $a = (binary)fread($fp, 4));
-$m = (binary)'';
+$L = unpack('V', $a = fread($fp, 4));
+$m = '';
 
 do {
 $read = 8192;
 if ($L[1] - strlen($m) < 8192) {
 $read = $L[1] - strlen($m);
 }
-$last = (binary)fread($fp, $read);
+$last = fread($fp, $read);
 $m .= $last;
 } while (strlen($last) && strlen($m) < $L[1]);
 
@@ -613,7 +613,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
 $stat[7] . ")");
 }
 
-if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
 die("Invalid internal .phar file (checksum error)");
 }
 
@@ -644,7 +644,7 @@ __HALT_COMPILER(); ?>
 "
 ============================================================================
 ============================================================================
-string(6698) "<?php
+string(6666) "<?php
 
 $web = 'the/web.php';
 
@@ -754,21 +754,21 @@ const GZ = 0x1000;
 const BZ2 = 0x2000;
 const MASK = 0x3000;
 const START = 'my/custom/thingy.php';
-const LEN = 6698;
+const LEN = 6666;
 
 static function go($return = false)
 {
 $fp = fopen(__FILE__, 'rb');
 fseek($fp, self::LEN);
-$L = unpack('V', $a = (binary)fread($fp, 4));
-$m = (binary)'';
+$L = unpack('V', $a = fread($fp, 4));
+$m = '';
 
 do {
 $read = 8192;
 if ($L[1] - strlen($m) < 8192) {
 $read = $L[1] - strlen($m);
 }
-$last = (binary)fread($fp, $read);
+$last = fread($fp, $read);
 $m .= $last;
 } while (strlen($last) && strlen($m) < $L[1]);
 
@@ -908,7 +908,7 @@ die("Invalid internal .phar file (size error " . strlen($data) . " != " .
 $stat[7] . ")");
 }
 
-if ($entry[3] != sprintf("%u", crc32((binary)$data) & 0xffffffff)) {
+if ($entry[3] != sprintf("%u", crc32($data) & 0xffffffff)) {
 die("Invalid internal .phar file (checksum error)");
 }
 
@@ -939,6 +939,6 @@ __HALT_COMPILER(); ?>
 "
 ============================================================================
 ============================================================================
-int(7076)
+int(7044)
 Illegal filename passed in for stub creation, was 401 characters long, and only 400 or less is allowed
 ===DONE===
index d754ac1df3f96d2fbcb3d74c8728d5469ac844ee..fce826a729996a348893db8234dcca53e4f65fe6 100644 (file)
@@ -47,12 +47,12 @@ __HALT_COMPILER();
 ?>
 --EXPECT--
 bool(false)
-int(6683)
+int(6651)
 bool(true)
 string(60) "<?php // tar-based phar archive stub file
 __HALT_COMPILER();"
 bool(true)
-int(6683)
+int(6651)
 bool(true)
-int(6683)
+int(6651)
 ===DONE===
index 58901ca7fc7365a47061108168530f1cde8ad328..496948b14c34a49cbf8b14ff6398864224821e69 100644 (file)
@@ -49,14 +49,14 @@ __HALT_COMPILER();
 ?>
 --EXPECT--
 bool(false)
-int(6683)
+int(6651)
 bool(true)
 string(60) "<?php // tar-based phar archive stub file
 __HALT_COMPILER();"
 bool(true)
 int(4096)
-int(6683)
+int(6651)
 bool(true)
 bool(true)
-int(6683)
+int(6651)
 ===DONE===
index 543c89b502037320f641cb6594c773116d57afd4..f4768194d1c2e030043049bc0eb4529250e21690 100644 (file)
@@ -49,14 +49,14 @@ __HALT_COMPILER();
 ?>
 --EXPECT--
 bool(false)
-int(6683)
+int(6651)
 bool(true)
 string(60) "<?php // tar-based phar archive stub file
 __HALT_COMPILER();"
 bool(true)
 int(8192)
-int(6683)
+int(6651)
 bool(true)
 bool(true)
-int(6683)
+int(6651)
 ===DONE===
index 9b095f11c269e000c003193718a48cf0146fbdad..544b96b0bd0806b1a5e73bcf5210db0ab03eeb50 100644 (file)
@@ -14,7 +14,7 @@ $fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
 
 $phar = new Phar($fname);
 $phar['a.txt'] = 'some text';
-$phar->setMetadata(b'hi');
+$phar->setMetadata('hi');
 $phar->stopBuffering();
 var_dump($phar->isFileFormat(Phar::TAR));
 var_dump(strlen($phar->getStub()));
@@ -54,7 +54,7 @@ __HALT_COMPILER();
 ?>
 --EXPECT--
 bool(false)
-int(6683)
+int(6651)
 string(2) "hi"
 bool(true)
 string(60) "<?php // tar-based phar archive stub file
@@ -62,10 +62,10 @@ __HALT_COMPILER();"
 string(2) "hi"
 bool(true)
 int(4096)
-int(6683)
+int(6651)
 string(2) "hi"
 bool(true)
 bool(true)
-int(6683)
+int(6651)
 string(2) "hi"
 ===DONE===
index cad6d9fc7f896b301305c7de880c1921cd868787..815656dbf671d509ac02a79a8bba81fc9d71c7cc 100644 (file)
@@ -46,12 +46,12 @@ __HALT_COMPILER();
 ?>
 --EXPECT--
 bool(false)
-int(6683)
+int(6651)
 bool(true)
 string(60) "<?php // zip-based phar archive stub file
 __HALT_COMPILER();"
 bool(true)
-int(6683)
+int(6651)
 bool(true)
-int(6683)
+int(6651)
 ===DONE===