mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Fix bug #73768 - Memory corruption when loading hostile phar
This commit is contained in:
parent
ca46d0acbc
commit
b28b8b2fee
3 changed files with 17 additions and 2 deletions
|
@ -981,7 +981,6 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
|
|||
/* if the alias is stored we enforce it (implicit overrides explicit) */
|
||||
if (alias && alias_len && (alias_len != (int)tmp_len || strncmp(alias, buffer, tmp_len)))
|
||||
{
|
||||
buffer[tmp_len] = '\0';
|
||||
php_stream_close(fp);
|
||||
|
||||
if (signature) {
|
||||
|
@ -989,7 +988,7 @@ static int phar_parse_pharfile(php_stream *fp, char *fname, int fname_len, char
|
|||
}
|
||||
|
||||
if (error) {
|
||||
spprintf(error, 0, "cannot load phar \"%s\" with implicit alias \"%s\" under different alias \"%s\"", fname, buffer, alias);
|
||||
spprintf(error, 0, "cannot load phar \"%s\" with implicit alias \"%.*s\" under different alias \"%s\"", fname, tmp_len, buffer, alias);
|
||||
}
|
||||
|
||||
efree(savebuf);
|
||||
|
|
BIN
ext/phar/tests/bug73768.phar
Normal file
BIN
ext/phar/tests/bug73768.phar
Normal file
Binary file not shown.
16
ext/phar/tests/bug73768.phpt
Normal file
16
ext/phar/tests/bug73768.phpt
Normal file
|
@ -0,0 +1,16 @@
|
|||
--TEST--
|
||||
Phar: PHP bug #73768: Memory corruption when loading hostile phar
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
chdir(__DIR__);
|
||||
try {
|
||||
$p = Phar::LoadPhar('bug73768.phar', 'alias.phar');
|
||||
echo "OK\n";
|
||||
} catch(PharException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
cannot load phar "%sbug73768.phar" with implicit alias "" under different alias "alias.phar"
|
Loading…
Add table
Add a link
Reference in a new issue