File: CVE-2015-7803.patch.org

package info (click to toggle)
php5 5.3.3.1-7%2Bsqueeze29
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 123,520 kB
  • ctags: 55,742
  • sloc: ansic: 633,963; php: 19,620; sh: 11,344; xml: 5,816; cpp: 2,400; yacc: 1,745; exp: 1,514; makefile: 1,019; pascal: 623; awk: 537; sql: 22
file content (101 lines) | stat: -rw-r--r-- 3,388 bytes parent folder | download
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From d698f0ae51f67c9cce870b09c59df3d6ba959244 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Mon, 28 Sep 2015 15:51:59 -0700
Subject: [PATCH] Fix bug #69720: Null pointer dereference in
 phar_get_fp_offset()

---
 ext/phar/tests/bug69720.phar | Bin 0 -> 8192 bytes
 ext/phar/tests/bug69720.phpt |  40 ++++++++++++++++++++++++++++++++++++++++
 ext/phar/util.c              |   6 +++++-
 3 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 ext/phar/tests/bug69720.phar
 create mode 100644 ext/phar/tests/bug69720.phpt

diff --git a/ext/phar/tests/bug69720.phar b/ext/phar/tests/bug69720.phar
new file mode 100644
index 0000000000000000000000000000000000000000..f62fb112802fef630cacb995d0a507904662970b
GIT binary patch
literal 8192
zcmeHL-EPw`6t1}70s&V%K(K@clgRAjBts6`RJtONRt*tXf-5T<hUQ{v)VLr(Xs^JV
z@GRUQ@irW<?M;J5Qzca=Y^73ldVcKh<m+eKFGlHPuQbzBzZeyrRtCipMNuWUwO@{i
zcNm1|6EI-=9klI3$UIt!Xu&WoO*+AnEu_8<DW4u<+dX|Y8hbm*u-EG+iAv<~+5Mf^
zQ|d+cSgPL1;ML3H{_BU2V(;+a&aLaPEH}p$5kS@>|NV1q(s!vz{nIR8F>-acIm;^n
zb33IFSk5m7erIUoj{g<Jnm3e!fgppoYS5S6qps{K5;tGPW!zQ-j4n-k%0FARCH9s2
z&no&KapXVn4WRa)>p!Z0mcJjj{R-4-B)%>XhTzo-a?WcZu%!Qci~oZrw*+%xugq_5
zr<C(${pSHhPX8;2HE&1-6JJa5M37IT)aZ|TLgEbf1U&xMd@+}C>kzPfhn8n$d0tch
z!;pjHf6INb>198W3e*vv{Weg|mDn}}{-*!Xr1;~4|E2#df`yNDwda4p3qZ&J4ZJKT
zR{D|sT4v{(2yQn6fgpGnq)A)~hy(%b$z#g!@hBCSk3Vav^<Z2OgRx)6xmM<Lfnk~8
z_ygu$*sUMB4P}qGZN&zfTBF2_|7G?ePtA0qTf6_eQvZ3dbpOxr02ny_*XZNAt~W67
p9)5Pe7q>gR5AMGCeeqo0yvTq2I{Ue9P8a78a0oaA90J>qz#o?I#LfT!

literal 0
HcmV?d00001

diff --git a/ext/phar/tests/bug69720.phpt b/ext/phar/tests/bug69720.phpt
new file mode 100644
index 0000000..43b701d
--- /dev/null
+++ b/ext/phar/tests/bug69720.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Phar - bug #69720 - Null pointer dereference in phar_get_fp_offset()
+--SKIPIF--
+<?php if (!extension_loaded("phar")) die("skip"); ?>
+--FILE--
+<?php
+try {
+    // open an existing phar
+    $p = new Phar(__DIR__."/bug69720.phar",0);
+    // Phar extends SPL's DirectoryIterator class
+	echo $p->getMetadata();
+    foreach (new RecursiveIteratorIterator($p) as $file) {
+        // $file is a PharFileInfo class, and inherits from SplFileInfo
+	$temp="";
+        $temp= $file->getFileName() . "\n";
+        $temp.=file_get_contents($file->getPathName()) . "\n"; // display contents
+	var_dump($file->getMetadata());
+    }
+}
+ catch (Exception $e) {
+    echo 'Could not open Phar: ', $e;
+}
+?>
+--EXPECTF--
+
+MY_METADATA_NULL
+
+Warning: file_get_contents(phar:///%s): failed to open stream: phar error: "test.php" is not a file in phar "%s.phar" in %s.php on line %d
+array(1) {
+  ["whatever"]=>
+  int(123)
+}
+object(DateTime)#2 (3) {
+  ["date"]=>
+  string(26) "2000-01-01 00:00:00.000000"
+  ["timezone_type"]=>
+  int(3)
+  ["timezone"]=>
+  string(3) "UTC"
+}
diff --git a/ext/phar/util.c b/ext/phar/util.c
index 2c41adf..69da7b9 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -494,7 +494,11 @@ really_get_entry:
 	(*ret)->is_tar = entry->is_tar;
 	(*ret)->fp = phar_get_efp(entry, 1 TSRMLS_CC);
 	if (entry->link) {
-		(*ret)->zero = phar_get_fp_offset(phar_get_link_source(entry TSRMLS_CC) TSRMLS_CC);
+		phar_entry_info *link = phar_get_link_source(entry TSRMLS_CC);
+		if(!link) {
+			return FAILURE;
+		}
+		(*ret)->zero = phar_get_fp_offset(link TSRMLS_CC);
 	} else {
 		(*ret)->zero = phar_get_fp_offset(entry TSRMLS_CC);
 	}
-- 
2.1.4