File: CVE-2015-6832.patch

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 (47 lines) | stat: -rw-r--r-- 1,666 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
From b7fa67742cd8d2b0ca0c0273b157f6ffee9ad6e2 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Sun, 26 Jul 2015 17:25:25 -0700
Subject: [PATCH] Fix bug #70068 (Dangling pointer in the unserialization of
 ArrayObject items)

---
 ext/spl/spl_array.c         | 90 +++++++++++++++++++++++----------------------
 ext/spl/tests/bug70068.phpt |  9 +++++
 2 files changed, 56 insertions(+), 43 deletions(-)
 create mode 100644 ext/spl/tests/bug70068.phpt

Index: php5-5.3.3.1/ext/spl/spl_array.c
===================================================================
--- php5-5.3.3.1.orig/ext/spl/spl_array.c	2015-10-19 11:28:15.000000000 +0200
+++ php5-5.3.3.1/ext/spl/spl_array.c	2015-10-19 11:30:41.000000000 +0200
@@ -1673,13 +1673,11 @@
 
 	ALLOC_INIT_ZVAL(pflags);
 	if (!php_var_unserialize(&pflags, &p, s + buf_len, var_hash_p TSRMLS_CC) || Z_TYPE_P(pflags) != IS_LONG) {
-		zval_ptr_dtor(&pflags);
 		goto outexcept;
 	}
 
 	--p; /* for ';' */
 	flags = Z_LVAL_P(pflags);
-	zval_ptr_dtor(&pflags);
 	/* flags needs to be verified and we also need to verify whether the next
 	 * thing we get is ';'. After that we require an 'm' or somethign else
 	 * where 'm' stands for members and anything else should be an array. If
@@ -1724,9 +1722,16 @@
 	zval_ptr_dtor(&pmembers);
 
 	/* done reading $serialized */
+        if (pflags) {
+                zval_ptr_dtor(&pflags);
+        }
+
 	return;
 
 outexcept:
+        if (pflags) {
+                zval_ptr_dtor(&pflags);
+        }
 	zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - (char *)buf), buf_len);
 	return;