From 2aec9cba4e8548ad4598d11132227816e863d4d0 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Wed, 13 Sep 2017 11:59:19 +0200
Subject: Update to 7.1.10RC1 Automatically load OpenSSL configuration file,
 from PHP 7.2

---
 failed.txt                          | 19 +++++++-------
 php-7.1.9-openssl-load-config.patch | 52 +++++++++++++++++++++++++++++++++++++
 php-upstream.patch                  | 42 ++++++++++++------------------
 php71.spec                          | 13 +++++++---
 4 files changed, 87 insertions(+), 39 deletions(-)
 create mode 100644 php-7.1.9-openssl-load-config.patch

diff --git a/failed.txt b/failed.txt
index e2b6913..8ec8555 100644
--- a/failed.txt
+++ b/failed.txt
@@ -1,26 +1,25 @@
-===== 7.1.9 (2017-08-31)
+===== 7.1.10RC1 (2017-09-14)
 
 $ grep -r 'Tests failed' /var/lib/mock/*/build.log
 
 /var/lib/mock/el6i/build.log:Tests failed    :     0
 /var/lib/mock/el6x/build.log:Tests failed    :     0
-/var/lib/mock/el7x/build.log:Tests failed    :     1
+/var/lib/mock/el7x/build.log:Tests failed    :     0
 /var/lib/mock/fc24i/build.log:Tests failed    :    0
 /var/lib/mock/fc24x/build.log:Tests failed    :    0
 /var/lib/mock/fc25i/build.log:Tests failed    :    0
-/var/lib/mock/fc25x/build.log:Tests failed    :    0
-/var/lib/mock/fc26i/build.log:Tests failed    :    0
-/var/lib/mock/fc26x/build.log:Tests failed    :    2
-/var/lib/mock/fc27x/build.log:Tests failed    :    1
+/var/lib/mock/fc25x/build.log:Tests failed    :    1
+/var/lib/mock/fc26i/build.log:Tests failed    :    2
+/var/lib/mock/fc26x/build.log:Tests failed    :    1
+/var/lib/mock/fc27i/build.log:Tests failed    :    0
+/var/lib/mock/fc27x/build.log:Tests failed    :    0
 
 
-el7x
+fc25x, fc26x
 	1	Bug #64438 proc_open hangs with stdin/out with 4097+ bytes [ext/standard/tests/streams/proc_open_bug64438.phpt]
-fc26x
+fc26i
 	5	proc_nice() basic behaviour [ext/standard/tests/general_functions/proc_nice_basic.phpt]
 	5	Check cli_process_title support on Unix [sapi/cli/tests/cli_process_title_unix.phpt]
-fc27x
-	2	substr_compare() [ext/standard/tests/strings/substr_compare.phpt]
 
 
 1	proc_open give erratic test results :(
diff --git a/php-7.1.9-openssl-load-config.patch b/php-7.1.9-openssl-load-config.patch
new file mode 100644
index 0000000..c998667
--- /dev/null
+++ b/php-7.1.9-openssl-load-config.patch
@@ -0,0 +1,52 @@
+Backported from PHP 7.2
+
+
+From 58df6a3b61f5cb914d899fbb44eecadad8098700 Mon Sep 17 00:00:00 2001
+From: Jakub Zelenka <bukka@php.net>
+Date: Mon, 28 Aug 2017 18:48:25 +0100
+Subject: [PATCH] Do not explicitly initialize and clean up OpenSSL for OpenSSL
+ 1.1
+
+From 1f843a8fb50de77a3f53a6b892a46d9e0afdfdd7 Mon Sep 17 00:00:00 2001
+From: Jakub Zelenka <bukka@php.net>
+Date: Mon, 28 Aug 2017 19:25:18 +0100
+Subject: [PATCH] Automatically load OpenSSL configuration file
+
+diff -up ./ext/openssl/openssl.c.loadconf ./ext/openssl/openssl.c
+--- ./ext/openssl/openssl.c.loadconf	2017-08-30 18:13:18.000000000 +0200
++++ ./ext/openssl/openssl.c	2017-09-06 13:11:47.212803443 +0200
+@@ -1409,6 +1409,8 @@ PHP_MINIT_FUNCTION(openssl)
+ 	le_x509 = zend_register_list_destructors_ex(php_x509_free, NULL, "OpenSSL X.509", module_number);
+ 	le_csr = zend_register_list_destructors_ex(php_csr_free, NULL, "OpenSSL X.509 CSR", module_number);
+ 
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
++	OPENSSL_config(NULL);
+ 	SSL_library_init();
+ 	OpenSSL_add_all_ciphers();
+ 	OpenSSL_add_all_digests();
+@@ -1421,6 +1423,9 @@ PHP_MINIT_FUNCTION(openssl)
+ #endif
+ 
+ 	SSL_load_error_strings();
++#else
++	OPENSSL_init_ssl(OPENSSL_INIT_LOAD_CONFIG, NULL);
++#endif
+ 
+ 	/* register a resource id number with OpenSSL so that we can map SSL -> stream structures in
+ 	 * OpenSSL callbacks */
+@@ -1585,12 +1590,15 @@ PHP_MINFO_FUNCTION(openssl)
+  */
+ PHP_MSHUTDOWN_FUNCTION(openssl)
+ {
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER)
+ 	EVP_cleanup();
+ 
+ 	/* prevent accessing locking callback from unloaded extension */
+ 	CRYPTO_set_locking_callback(NULL);
+ 	/* free allocated error strings */
+ 	ERR_free_strings();
++	CONF_modules_free();
++#endif
+ 
+ 	php_unregister_url_stream_wrapper("https");
+ 	php_unregister_url_stream_wrapper("ftps");
diff --git a/php-upstream.patch b/php-upstream.patch
index 448fd7c..84862e9 100644
--- a/php-upstream.patch
+++ b/php-upstream.patch
@@ -1,30 +1,20 @@
-From 3239f6d6798d86fdbf8e03aa741d9990bcfffe79 Mon Sep 17 00:00:00 2001
-From: Remi Collet <remi@php.net>
-Date: Thu, 31 Aug 2017 07:55:45 +0200
-Subject: [PATCH] move AC_DEFINE in the right position (in bundled lib
- conditon)
+From 7674b5e5749e8c0076357167ca553f153c94e6d1 Mon Sep 17 00:00:00 2001
+From: Anatol Belski <ab@php.net>
+Date: Tue, 12 Sep 2017 18:17:28 +0200
+Subject: [PATCH] Fix test failure on 32-bit
 
 ---
- ext/sqlite3/config0.m4 | 2 +-
+ ext/standard/tests/serialize/bug74103.phpt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4
-index 0e5fbc5..78fd622 100644
---- a/ext/sqlite3/config0.m4
-+++ b/ext/sqlite3/config0.m4
-@@ -85,11 +85,11 @@ if test $PHP_SQLITE3 != "no"; then
-       other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
-     fi
- 
-+    AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
-     PHP_SQLITE3_CFLAGS="-I@ext_srcdir@/libsqlite $other_flags $threadsafe_flags $debug_flags"
-     PHP_INSTALL_HEADERS([ext/sqlite3/libsqlite/sqlite3.h])
-   fi
- 
--  AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
-   AC_DEFINE(HAVE_SQLITE3,1,[ ])
- 
-   sqlite3_sources="sqlite3.c $sqlite3_extra_sources"
--- 
-2.1.4
-
+diff --git a/ext/standard/tests/serialize/bug74103.phpt b/ext/standard/tests/serialize/bug74103.phpt
+index 3d474b31b1cd..97076ffe466e 100644
+--- a/ext/standard/tests/serialize/bug74103.phpt
++++ b/ext/standard/tests/serialize/bug74103.phpt
+@@ -5,5 +5,5 @@ Bug #74103: heap-use-after-free when uns
+ var_dump(unserialize('a:7:{i:0;i:04;s:1:"a";i:2;i:9617006;i:4;s:1:"a";i:4;s:1:"a";R:5;s:1:"7";R:3;s:1:"a";R:5;;s:18;}}'));
+ ?>
+ --EXPECTF--
+-Notice: unserialize(): Error at offset 64 of 96 bytes in %s on line %d
++Notice: unserialize(): Error at offset %d of %d bytes in %s on line %d
+ bool(false)
diff --git a/php71.spec b/php71.spec
index 1427219..043f696 100644
--- a/php71.spec
+++ b/php71.spec
@@ -107,13 +107,13 @@
 %global db_devel  libdb-devel
 %endif
 
-%global upver        7.1.9
-#global rcver        RC1
+%global upver        7.1.10
+%global rcver        RC1
 
 Summary: PHP scripting language for creating dynamic web sites
 Name: php
 Version: %{upver}%{?rcver:~%{rcver}}
-Release: 2%{?dist}
+Release: 1%{?dist}
 # All files licensed under PHP version 3.01, except
 # Zend is licensed under Zend
 # TSRM is licensed under BSD
@@ -162,6 +162,8 @@ Patch45: php-5.6.3-ldap_r.patch
 Patch46: php-7.0.0-fixheader.patch
 # drop "Configure command" from phpinfo output
 Patch47: php-5.6.3-phpinfo.patch
+# Automatically load OpenSSL configuration file
+Patch48: php-7.1.9-openssl-load-config.patch
 
 # RC Patch
 Patch91: php-5.6.3-oci8conf.patch
@@ -1006,6 +1008,7 @@ support for JavaScript Object Notation (JSON) to PHP.
 %endif
 %patch46 -p1 -b .fixheader
 %patch47 -p1 -b .phpinfo
+%patch48 -p1 -b .loadconf
 
 %patch91 -p1 -b .remi-oci8
 
@@ -2041,6 +2044,10 @@ fi
 
 
 %changelog
+* Wed Sep 13 2017 Remi Collet <remi@remirepo.net> - 7.1.10~RC1-1
+- Update to 7.1.10RC1
+- Automatically load OpenSSL configuration file, from PHP 7.2
+
 * Thu Aug 31 2017 Remi Collet <remi@fedoraproject.org> - 7.1.9-2
 - add patch for EL-6, fix undefined symbol: sqlite3_errstr
 
-- 
cgit