xref: /PHP-7.4/ext/zip/tests/pecl12414.phpt (revision 26dfce7f)
1--TEST--
2Bug #12414 ( extracting files from damaged archives)
3--SKIPIF--
4<?php
5/*$ */
6if(!extension_loaded('zip')) die('skip');
7 ?>
8--FILE--
9<?php
10$filename = 'MYLOGOV2.GFX';
11$zipname = __DIR__ . "/pecl12414.zip";
12$za = new ZipArchive();
13$res =$za->open($zipname);
14if ($res === TRUE) {
15	$finfo=$za->statName($filename);
16	$file_size=$finfo['size'];
17
18	if($file_size>0) {
19		$contents=$za->getFromName($filename);
20
21		echo "ZIP contents size: " . strlen($contents) . "\n";
22		if(strlen($contents)!=$file_size) {
23			echo "zip_readfile recorded data does not match unpacked size: " . $zipname . " : " . $filename;
24		}
25	} else {
26		$contents=false;
27		echo "zip_readfile could not open stream from zero length file " . $zipname . " : " .$filename;
28	}
29
30	$za->close();
31} else {
32	echo "zip_readfile could not read from " . $zipname . " : " . $filename;
33}
34
35?>
36--EXPECTF--
37zip_readfile could not read from %specl12414.zip : MYLOGOV2.GFX
38