com php-src: Fixed bug #71331 - Uninitialized pointer in phar_make_dirstream(): ext/phar/dirstream.c ext /phar/tar.c ext/phar/tests/bug71331.phpt ext/
phar/tests/bug71331.tar

From: Date: Thu, 28 Apr 2016 17:57:44 +0000
Subject: com php-src: Fixed bug #71331 - Uninitialized pointer in phar_make_dirstream(): ext/phar/dirstream.c ext /phar/tar.c ext/phar/tests/bug71331.phpt ext/
phar/tests/bug71331.tar
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-91995@lists.php.net to get a copy of this message
Commit: 9649ca1630433473a307d015ba1a79a4a7a779f5 Author: Stanislav Malyshev <stas@php.net> Thu, 14 Jan 2016 22:58:40 -0800 Committer: Lior Kaplan <kaplanlior@gmail.com> Thu, 28 Apr 2016 20:57:44 +0300 Parents: 008f983ba6b93372035babd19189bb7272d05997 Branches: PHP-5.5 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9649ca1630433473a307d015ba1a79a4a7a779f5 Log: Fixed bug #71331 - Uninitialized pointer in phar_make_dirstream() Bugs: https://bugs.php.net/71331 Changed paths: M ext/phar/dirstream.c M ext/phar/tar.c A ext/phar/tests/bug71331.phpt A ext/phar/tests/bug71331.tar Diff: diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index 75cf049..94958a2 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -207,6 +207,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) zend_hash_internal_pointer_reset(manifest); while (FAILURE != zend_hash_has_more_elements(manifest)) { + keylen = 0; if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) { break; } @@ -214,7 +215,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) PHAR_STR(key, str_key); if (keylen <= (uint)dirlen) { - if (keylen < (uint)dirlen || !strncmp(str_key, dir, dirlen)) { + if (keylen == 0 || keylen < (uint)dirlen || !strncmp(str_key, dir, dirlen)) { PHAR_STR_FREE(str_key); if (SUCCESS != zend_hash_move_forward(manifest)) { break; diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 3a4bd49..bf19e08 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -356,7 +356,7 @@ bail: entry.filename_len = entry.uncompressed_filesize; /* Check for overflow - bug 61065 */ - if (entry.filename_len == UINT_MAX) { + if (entry.filename_len == UINT_MAX || entry..filename_len == 0) { if (error) { spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (invalid entry size)", fname); } diff --git a/ext/phar/tests/bug71331.phpt b/ext/phar/tests/bug71331.phpt new file mode 100644 index 0000000...106fd54 --- /dev/null +++ b/ext/phar/tests/bug71331.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #71331 (Uninitialized pointer in phar_make_dirstream()) +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip"); ?> +--FILE-- +<?php +$p = new PharData(__DIR__."/bug71331.tar"); +?> +DONE +--EXPECTF-- +Fatal error: Uncaught exception 'UnexpectedValueException' with message 'phar error: "%s/bug71331.tar" is a corrupted tar file (invalid entry size)' in %s/bug71331.php:2 +Stack trace: +#0 %s/bug71331.php(2): PharData->__construct('%s') +#1 {main} + thrown in %s/bug71331.php on line 2 \ No newline at end of file diff --git a/ext/phar/tests/bug71331.tar b/ext/phar/tests/bug71331.tar new file mode 100644 index 0000000..14eec28 Binary files /dev/null and b/ext/phar/tests/bug71331.tar differ

« previous php.cvs (#91995) next »