當使用PHP壓縮類提取一個zip文件(其實這是不好的,但誰知道?),PHP拉鍊無限循環
$ unzip -t 1.zip
file #47: bad zipfile offset (local header sig): 574665
...
At least one error was detected in 1.zip.
<?php
function unzip($apkpath, $dirname) { //
$zip = new ZipArchive;
$res = $zip->open($apkpath);
if ($res === TRUE) {
$zip->extractTo($dirname);
$zip->close();
return true;
} else {
return false;
}
}
unzip('com.nd.sms.zip', '2'); // It's ok
//unzip('1.zip', '2'); //this line go into infinite loop and very heigh cpu
unzip('com.nd.sms.zip', '2');
?>
任何人都知道如何安全地使用ZipArchive,或其他附加信息替代,或者某種方式來檢查壓縮文件是否有效? 另外,我使用php5.3.14 + ubuntu。
我知道有, https://bugs.php.net/bug.php?id=53230 https://bugs.php.net/bug.php?id=57905
出於安全原因更新系統庫。那你很好。請聯繫您的系統管理員,瞭解您擁有的選項。 – hakre 2012-07-21 09:54:32