summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-bug79797.patch52
-rw-r--r--php-bug79877.patch84
-rw-r--r--php.spec15
3 files changed, 149 insertions, 2 deletions
diff --git a/php-bug79797.patch b/php-bug79797.patch
new file mode 100644
index 0000000..f29d1cf
--- /dev/null
+++ b/php-bug79797.patch
@@ -0,0 +1,52 @@
+Partial, without binary part
+
+
+
+From d7980cd5ef5862d9a01a0f34ee44bec07be88096 Mon Sep 17 00:00:00 2001
+From: "Christoph M. Becker" <cmbecker69@gmx.de>
+Date: Tue, 14 Jul 2020 17:04:24 +0200
+Subject: [PATCH] Fix #79797: Use of freed hash key in the phar_parse_zipfile
+ function
+
+We must not use heap memory after we freed it.
+
+(cherry picked from commit 7355ab81763a3d6a04ac11660e6a16d58838d187)
+---
+ NEWS | 6 ++++++
+ ext/phar/tests/bug79797.phar | Bin 0 -> 274 bytes
+ ext/phar/tests/bug79797.phpt | 14 ++++++++++++++
+ ext/phar/zip.c | 2 +-
+ 4 files changed, 21 insertions(+), 1 deletion(-)
+ create mode 100644 ext/phar/tests/bug79797.phar
+ create mode 100644 ext/phar/tests/bug79797.phpt
+
+diff --git a/NEWS b/NEWS
+index b53c9e28cb..501283aabe 100644
+--- a/NEWS
++++ b/NEWS
+@@ -1,6 +1,12 @@
+ PHP NEWS
+ |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
++Backported from 7.2.33
++
++- Phar:
++ . Fixed bug #79797 (Use of freed hash key in the phar_parse_zipfile
++ function). (CVE-2020-7068) (cmb)
++
+ Backported from 7.2.31
+
+ - Core:
+diff --git a/ext/phar/zip.c b/ext/phar/zip.c
+index ed156a2d00..3ab02ab35a 100644
+--- a/ext/phar/zip.c
++++ b/ext/phar/zip.c
+@@ -682,7 +682,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, int fname_len, char *alias,
+ efree(actual_alias);
+ }
+
+- zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), actual_alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
++ zend_hash_add(&(PHAR_GLOBALS->phar_alias_map), mydata->alias, mydata->alias_len, (void*)&mydata, sizeof(phar_archive_data*), NULL);
+ } else {
+ phar_archive_data **fd_ptr;
+
diff --git a/php-bug79877.patch b/php-bug79877.patch
new file mode 100644
index 0000000..d10daa6
--- /dev/null
+++ b/php-bug79877.patch
@@ -0,0 +1,84 @@
+From 5389b1e6bb048369715aba73473625d760a39e89 Mon Sep 17 00:00:00 2001
+From: "Christoph M. Becker" <cmbecker69@gmx.de>
+Date: Tue, 21 Jul 2020 11:07:43 +0200
+Subject: [PATCH] Fix #79877: getimagesize function silently truncates after a
+ null byte
+
+We have to check for NUL bytes if `getimagesize()` has been called.
+
+(cherry picked from commit ff577b04c0d250473a0ef46f8e332960fec3ca2c)
+---
+ NEWS | 4 ++++
+ ext/standard/image.c | 5 +++++
+ ext/standard/tests/image/bug79877.phpt | 9 +++++++++
+ 3 files changed, 18 insertions(+)
+ create mode 100644 ext/standard/tests/image/bug79877.phpt
+
+diff --git a/NEWS b/NEWS
+index 501283aabe..cf34011622 100644
+--- a/NEWS
++++ b/NEWS
+@@ -3,6 +3,10 @@ PHP NEWS
+
+ Backported from 7.2.33
+
++- Core:
++ . Fixed bug #79877 (getimagesize function silently truncates after a null
++ byte) (cmb)
++
+ - Phar:
+ . Fixed bug #79797 (Use of freed hash key in the phar_parse_zipfile
+ function). (CVE-2020-7068) (cmb)
+diff --git a/ext/standard/image.c b/ext/standard/image.c
+index d58d543abd..f663e7c0c2 100644
+--- a/ext/standard/image.c
++++ b/ext/standard/image.c
+@@ -1398,6 +1398,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
+ return;
+ }
+
++ if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) {
++ php_error_docref(NULL, E_WARNING, "Invalid path");
++ return;
++ }
++
+ if (argc == 2) {
+ zval_dtor(*info);
+ array_init(*info);
+diff --git a/ext/standard/tests/image/bug79877.phpt b/ext/standard/tests/image/bug79877.phpt
+new file mode 100644
+index 0000000000..92e93e59e5
+--- /dev/null
++++ b/ext/standard/tests/image/bug79877.phpt
+@@ -0,0 +1,9 @@
++--TEST--
++Bug #79877 (getimagesize function silently truncates after a null byte)
++--FILE--
++<?php
++var_dump(getimagesize("/tmp/a.png\0xx"));
++?>
++--EXPECTF--
++Warning: getimagesize(): Invalid path in %s on line %d
++NULL
+From bcec8f78b57189a654524b737562d1da235c6553 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Tue, 4 Aug 2020 07:40:22 +0200
+Subject: [PATCH] ZTS fix
+
+---
+ ext/standard/image.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/ext/standard/image.c b/ext/standard/image.c
+index f663e7c0c2..db64b3a48e 100644
+--- a/ext/standard/image.c
++++ b/ext/standard/image.c
+@@ -1399,7 +1399,7 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
+ }
+
+ if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) {
+- php_error_docref(NULL, E_WARNING, "Invalid path");
++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid path");
+ return;
+ }
+
diff --git a/php.spec b/php.spec
index ceb5e8a..75011d2 100644
--- a/php.spec
+++ b/php.spec
@@ -146,7 +146,7 @@
Summary: PHP scripting language for creating dynamic web sites
Name: %{?scl_prefix}php
Version: 5.6.40
-Release: 21%{?dist}
+Release: 22%{?dist}
# All files licensed under PHP version 3.01, except
# Zend is licensed under Zend
# TSRM is licensed under BSD
@@ -242,6 +242,8 @@ Patch239: php-bug79329.patch
Patch240: php-bug79330.patch
Patch241: php-bug79465.patch
Patch242: php-bug78875.patch
+Patch243: php-bug79797.patch
+Patch244: php-bug79877.patch
# Fixes for tests (300+)
# Factory is droped from system tzdata
@@ -949,7 +951,7 @@ support for using the enchant library to PHP.
%if 0%{?rhel}
%patch9 -p1 -b .curltls
%endif
-%if 0%{?fedora} >= 29 || 0%{?rhel} >= 8
+%if 0%{?fedora} >= 29 || 0%{?rhel} >= 7
%patch10 -p1 -b .icu62
%endif
%patch11 -p1 -b .gcc10
@@ -1008,6 +1010,8 @@ sed -e 's/php-devel/%{?scl_prefix}php-devel/' -i scripts/phpize.in
%patch240 -p1 -b .bug79330
%patch241 -p1 -b .bug79465
%patch242 -p1 -b .bug78875
+%patch243 -p1 -b .bug79797
+%patch244 -p1 -b .bug79877
# Fixes for tests
%patch300 -p1 -b .datetests
@@ -1953,6 +1957,13 @@ EOF
%changelog
+* Tue Aug 4 2020 Remi Collet <remi@remirepo.net> - 5.6.40-22
+- Core:
+ Fix #79877 getimagesize function silently truncates after a null byte
+- Phar:
+ Fix #79797 use of freed hash key in the phar_parse_zipfile function
+ CVE-2020-7068
+
* Wed May 13 2020 Remi Collet <remi@remirepo.net> - 5.6.40-21
- Core:
Fix #78875 Long filenames cause OOM and temp files are not cleaned