summaryrefslogtreecommitdiffstats
path: root/bug70433.patch
blob: 6d1049f834f9f258f64c38d44f681038d3cf444e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Backported from 5.5 for 5.4 by Remi Collet
binary patch dropped


From e78ac461dbefb7c4a3e9fde78d50fbc56b7b0183 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Mon, 28 Sep 2015 17:12:35 -0700
Subject: [PATCH] FIx bug #70433 - Uninitialized pointer in phar_make_dirstream
 when zip entry filename is "/"

From 1ddf72180a52d247db88ea42a3e35f824a8fbda1 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Mon, 28 Sep 2015 21:37:26 -0700
Subject: [PATCH] Better fix for bug #70433

---
 ext/phar/dirstream.c | 2 +-
 ext/phar/util.c      | 2 +-
 ext/phar/zip.c       | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/ext/phar/util.c b/ext/phar/util.c
index e7decda..303daed 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -2248,7 +2248,7 @@ void phar_add_virtual_dirs(phar_archive_data *phar, char *filename, int filename

 	while ((s = zend_memrchr(filename, '/', filename_len))) {
 		filename_len = s - filename;
-		if (FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
+		if (!filename_len || FAILURE == zend_hash_add_empty_element(&phar->virtual_dirs, filename, filename_len)) {
 			break;
 		}
 	}
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 142165c..e4883d3 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -396,7 +396,9 @@ foundit:
 
 		if (entry.filename[entry.filename_len - 1] == '/') {
 			entry.is_dir = 1;
-			entry.filename_len--;
+			if(entry.filename_len > 1) {
+				entry.filename_len--;
+			}
 			entry.flags |= PHAR_ENT_PERM_DEF_DIR;
 		} else {
 			entry.is_dir = 0;
-- 
2.1.4