-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #76929: zip-based phar does not respect phar.require_hash
Based on the patch provided by david at bamsoftware. Closes GH-6517.
- Loading branch information
Showing
24 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--TEST-- | ||
Phar: zip-based phar, require_hash=1, no signature | ||
--SKIPIF-- | ||
<?php if (!extension_loaded('phar')) die('skip'); ?> | ||
--INI-- | ||
phar.readonly=1 | ||
phar.require_hash=0 | ||
--FILE-- | ||
<?php | ||
ini_set('phar.require_hash', 1); | ||
include __DIR__ . '/files/zipmaker.php.inc'; | ||
$fname = __DIR__ . '/require_hash.phar.zip'; | ||
$alias = 'phar://' . $fname; | ||
$fname2 = __DIR__ . '/require_hash.zip'; | ||
|
||
$zip = new zipmaker($fname); | ||
$zip->init(); | ||
$zip->addFile('zip_001.php', '<?php var_dump(__FILE__);'); | ||
$zip->addFile('internal/file/here', "hi there!\n"); | ||
$zip->addFile('.phar/stub.php', "__HALT_COMPILER();"); | ||
$zip->close(); | ||
|
||
try { | ||
$phar = new Phar($fname); | ||
var_dump($phar->getStub()); | ||
} catch (Exception $e) { | ||
echo $e->getMessage()."\n"; | ||
} | ||
ini_set('phar.require_hash', 0); | ||
try { | ||
$phar = new PharData($fname2); | ||
$phar['file'] = 'hi'; | ||
var_dump($phar->getSignature()); | ||
$phar->setSignatureAlgorithm(Phar::MD5); | ||
var_dump($phar->getSignature()); | ||
} catch (Exception $e) { | ||
echo $e->getMessage()."\n"; | ||
} | ||
|
||
?> | ||
===DONE=== | ||
--CLEAN-- | ||
<?php | ||
@unlink(__DIR__ . '/require_hash.phar.zip'); | ||
@unlink(__DIR__ . '/require_hash.zip'); | ||
?> | ||
--EXPECTF-- | ||
zip-based phar "%srequire_hash.phar.zip" does not have a signature | ||
bool(false) | ||
array(2) { | ||
["hash"]=> | ||
string(32) "%s" | ||
["hash_type"]=> | ||
string(3) "MD5" | ||
} | ||
===DONE=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters