mirror of
https://github.com/php/php-src.git
synced 2026-04-22 15:38:49 +02:00
Fix int overflows in phar (bug #73764)
This commit is contained in:
+2
-2
@@ -1055,7 +1055,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
|
||||
entry.is_persistent = mydata->is_persistent;
|
||||
|
||||
for (manifest_index = 0; manifest_index < manifest_count; ++manifest_index) {
|
||||
if (buffer + 4 > endbuffer) {
|
||||
if (buffer + 24 > endbuffer) {
|
||||
MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)")
|
||||
}
|
||||
|
||||
@@ -1069,7 +1069,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
|
||||
entry.manifest_pos = manifest_index;
|
||||
}
|
||||
|
||||
if (entry.filename_len + 20 > endbuffer - buffer) {
|
||||
if (entry.filename_len > endbuffer - buffer - 20) {
|
||||
MAPPHAR_FAIL("internal corruption of phar \"%s\" (truncated manifest entry)");
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Phar: PHP bug #73764: Crash while loading hostile phar archive
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
chdir(__DIR__);
|
||||
try {
|
||||
$p = Phar::LoadPhar('bug73764.phar', 'alias.phar');
|
||||
echo "OK\n";
|
||||
} catch(PharException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
internal corruption of phar "%sbug73764.phar" (truncated manifest entry)
|
||||
Reference in New Issue
Block a user