summaryrefslogtreecommitdiffstats
path: root/php-bug77569.patch
blob: 459372a7d0d6bc79622f54555c9c9ae76c7d9efb (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
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
From 2ee92db814827e4484d997c91b75034995e6f99e Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Thu, 13 Feb 2020 15:13:26 +0100
Subject: [PATCH] Fix #77569: Write Acess Violation in DomImplementation

We must not assume that the zval IS_STRING.

(cherry picked from commit cec8b24c848bab8562c82422f3692c193f0afcdb)
---
 NEWS                        |  6 ++++++
 ext/dom/document.c          |  2 +-
 ext/dom/tests/bug77569.phpt | 14 ++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 ext/dom/tests/bug77569.phpt

diff --git a/NEWS b/NEWS
index e311fc78cc..0743c78268 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,12 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
+Backported from 7.2.28
+
+- DOM:
+  . Fixed bug #77569: (Write Acess Violation in DomImplementation). (Nikita,
+    cmb)
+
 Backported from 7.2.27
 
 - Mbstring:
diff --git a/ext/dom/document.c b/ext/dom/document.c
index c9e1802f78..11ef4aa818 100644
--- a/ext/dom/document.c
+++ b/ext/dom/document.c
@@ -341,7 +341,7 @@ int dom_document_encoding_write(dom_object *obj, zval *newval)
 
 	str = zval_get_string(newval);
 
-	handler = xmlFindCharEncodingHandler(Z_STRVAL_P(newval));
+	handler = xmlFindCharEncodingHandler(ZSTR_VAL(str));
 
     if (handler != NULL) {
 		xmlCharEncCloseFunc(handler);
diff --git a/ext/dom/tests/bug77569.phpt b/ext/dom/tests/bug77569.phpt
new file mode 100644
index 0000000000..f0f3566708
--- /dev/null
+++ b/ext/dom/tests/bug77569.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #77569 (Write Acess Violation in DomImplementation)
+--SKIPIF--
+<?php
+if (!extension_loaded('dom')) die('skip dom extension not available');
+?>
+--FILE--
+<?php
+$imp = new DOMImplementation;
+$dom = $imp->createDocument("", "");
+$dom->encoding = null;
+?>
+--EXPECTF--
+Warning: main(): Invalid Document Encoding in %s on line %d
From 08374ddcc45940dc341afc68de505599f1839e64 Mon Sep 17 00:00:00 2001
From: "Christoph M. Becker" <cmbecker69@gmx.de>
Date: Fri, 14 Feb 2020 09:21:13 +0100
Subject: [PATCH] Fix typo in recent bugfix

(cherry picked from commit 8308196c97418ba4c8381bed0962ae160623027a)
---
 NEWS                        | 2 +-
 ext/dom/tests/bug77569.phpt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 0743c78268..7e220aae24 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ PHP                                                                        NEWS
 Backported from 7.2.28
 
 - DOM:
-  . Fixed bug #77569: (Write Acess Violation in DomImplementation). (Nikita,
+  . Fixed bug #77569: (Write Access Violation in DomImplementation). (Nikita,
     cmb)
 
 Backported from 7.2.27
diff --git a/ext/dom/tests/bug77569.phpt b/ext/dom/tests/bug77569.phpt
index f0f3566708..9eef2af65a 100644
--- a/ext/dom/tests/bug77569.phpt
+++ b/ext/dom/tests/bug77569.phpt
@@ -1,5 +1,5 @@
 --TEST--
-Bug #77569 (Write Acess Violation in DomImplementation)
+Bug #77569 (Write Access Violation in DomImplementation)
 --SKIPIF--
 <?php
 if (!extension_loaded('dom')) die('skip dom extension not available');