xref: /PHP-7.4/ext/phar/tests/bug73809.phpt (revision c283f53b)
1--TEST--
2Bug #73809 (Phar Zip parse crash - mmap fail)
3--SKIPIF--
4<?php
5if (!extension_loaded('phar')) die('skip phar extension not available');
6if (!extension_loaded('zip')) die('skip zip extension not available');
7?>
8--FILE--
9<?php
10// create the ZIP to be tested
11$zip = new ZipArchive;
12$zip->open(__DIR__ . '/73809.zip', ZipArchive::CREATE);
13$zip->addFromString('73809.txt', 'yada yada');
14$zip->addFromString('.phar/signature.bin', str_repeat('*', 64 * 1024 + 1));
15$zip->setCompressionName('.phar/signature.bin', ZipArchive::CM_STORE);
16var_dump($zip->close());
17
18try {
19    $phar = new PharData(__DIR__ . '/73809.zip');
20} catch (Exception $ex) {
21    echo $ex->getMessage(), PHP_EOL;
22}
23?>
24--CLEAN--
25<?php
26@unlink(__DIR__ . '/73809.zip');
27?>
28--EXPECTF--
29bool(true)
30phar error: signatures larger than 64 KiB are not supported in zip-based phar "%s"
31