Blame SOURCES/php-5.6.5-CVE-2015-7804.patch

925b0d
Patch cleanup for 5.6.5
925b0d
Binary diff removed
925b0d
925b0d
From e78ac461dbefb7c4a3e9fde78d50fbc56b7b0183 Mon Sep 17 00:00:00 2001
925b0d
From: Stanislav Malyshev <stas@php.net>
925b0d
Date: Mon, 28 Sep 2015 17:12:35 -0700
925b0d
Subject: [PATCH] FIx bug #70433 - Uninitialized pointer in phar_make_dirstream
925b0d
 when zip entry filename is "/"
925b0d
925b0d
---
925b0d
 ext/phar/dirstream.c         |   2 +-
925b0d
 ext/phar/tests/bug70433.phpt |  23 +++++++++++++++++++++++
925b0d
 ext/phar/tests/bug70433.zip  | Bin 0 -> 264 bytes
925b0d
 3 files changed, 24 insertions(+), 1 deletion(-)
925b0d
 create mode 100644 ext/phar/tests/bug70433.phpt
925b0d
 create mode 100755 ext/phar/tests/bug70433.zip
925b0d
925b0d
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
925b0d
index 75cf049..4728e29 100644
925b0d
--- a/ext/phar/dirstream.c
925b0d
+++ b/ext/phar/dirstream.c
925b0d
@@ -198,7 +198,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
925b0d
 	zend_hash_internal_pointer_reset(manifest);
925b0d
 
925b0d
 	while (FAILURE != zend_hash_has_more_elements(manifest)) {
925b0d
-		if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
925b0d
+		if (HASH_KEY_IS_STRING != zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
925b0d
 			break;
925b0d
 		}
925b0d
925b0d
From 1ddf72180a52d247db88ea42a3e35f824a8fbda1 Mon Sep 17 00:00:00 2001
925b0d
From: Stanislav Malyshev <stas@php.net>
925b0d
Date: Mon, 28 Sep 2015 21:37:26 -0700
925b0d
Subject: [PATCH] Better fix for bug #70433
925b0d
925b0d
---
925b0d
 ext/phar/dirstream.c | 2 +-
925b0d
 ext/phar/util.c      | 2 +-
925b0d
 ext/phar/zip.c       | 4 +++-
925b0d
 3 files changed, 5 insertions(+), 3 deletions(-)
925b0d
925b0d
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
925b0d
index 4728e29..75cf049 100644
925b0d
--- a/ext/phar/dirstream.c
925b0d
+++ b/ext/phar/dirstream.c
925b0d
@@ -198,7 +198,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
925b0d
 	zend_hash_internal_pointer_reset(manifest);
925b0d
 
925b0d
 	while (FAILURE != zend_hash_has_more_elements(manifest)) {
925b0d
-		if (HASH_KEY_IS_STRING != zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
925b0d
+		if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &str_key, &keylen, &unused, 0, NULL)) {
925b0d
 			break;
925b0d
 		}
925b0d
 
925b0d
diff --git a/ext/phar/util.c b/ext/phar/util.c
925b0d
index e7decda..303daed 100644
925b0d
--- a/ext/phar/util.c
925b0d
+++ b/ext/phar/util.c
925b0d
@@ -1970,7 +1970,7 @@ void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename
925b0d
 
925b0d
 	while ((s = zend_memrchr(filename, '/', filename_len))) {
925b0d
 		filename_len = s - filename;
925b0d
-		if (FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
925b0d
+		if (!filename_len || FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
925b0d
 			break;
925b0d
 		}
925b0d
 	}
925b0d
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
925b0d
index 142165c..e4883d3 100644
925b0d
--- a/ext/phar/zip.c
925b0d
+++ b/ext/phar/zip.c
925b0d
@@ -396,7 +396,9 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
925b0d
 
925b0d
 		if (entry.filename[entry.filename_len - 1] == '/') {
925b0d
 			entry.is_dir = 1;
925b0d
-			entry.filename_len--;
925b0d
+			if(entry.filename_len > 1) {
925b0d
+				entry.filename_len--;
925b0d
+			}
925b0d
 			entry.flags |= PHAR_ENT_PERM_DEF_DIR;
925b0d
 		} else {
925b0d
 			entry.is_dir = 0;