summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-09-03 15:20:59 +0200
committerRemi Collet <remi@remirepo.net>2018-09-03 15:20:59 +0200
commit7afc6f39e746eb7ac95e584beebc0ad13844a005 (patch)
tree32c51e1fa23bfafa53b1be3f103d898fcf5fef52
parentce31144456aba8023ba780fe9114d2325323b639 (diff)
add patch for PHP 7.3 on 32-bit from https://github.com/nbs-system/snuffleupagus/pull/242
-rw-r--r--242.patch188
-rw-r--r--php-snuffleupagus.spec15
2 files changed, 200 insertions, 3 deletions
diff --git a/242.patch b/242.patch
new file mode 100644
index 0000000..710276a
--- /dev/null
+++ b/242.patch
@@ -0,0 +1,188 @@
+From 10b548f43e07685f451f22e96c246d1f5b7f486e Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Mon, 3 Sep 2018 15:09:00 +0200
+Subject: [PATCH 1/2] Fix #241 segfault on 32-bit related to bad protype
+
+---
+ src/php_snuffleupagus.h | 5 +++++
+ src/sp_disabled_functions.c | 4 ++--
+ src/sp_harden_rand.c | 4 ++--
+ src/sp_sloppy.c | 4 ++--
+ src/sp_unserialize.c | 4 ++--
+ src/sp_utils.c | 4 ++--
+ src/sp_utils.h | 6 ++----
+ src/sp_wrapper.c | 2 +-
+ 8 files changed, 18 insertions(+), 15 deletions(-)
+
+diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h
+index bc927a0..0bdf602 100644
+--- a/src/php_snuffleupagus.h
++++ b/src/php_snuffleupagus.h
+@@ -25,6 +25,11 @@
+ #include "zend_string.h"
+ #include "zend_extensions.h"
+
++/* Compatibility */
++#if PHP_VERSION_ID < 70200
++typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS);
++#endif
++
+ #include "sp_pcre_compat.h"
+ #include "sp_list.h"
+ #include "sp_tree.h"
+diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c
+index 835776b..b8ec845 100644
+--- a/src/sp_disabled_functions.c
++++ b/src/sp_disabled_functions.c
+@@ -501,7 +501,7 @@ bool should_drop_on_ret(const zval* return_value, const sp_list_node* config,
+ }
+
+ ZEND_FUNCTION(check_disabled_function) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+ const char* current_function_name = get_active_function_name(TSRMLS_C);
+
+ if (true == should_disable_ht(
+@@ -566,7 +566,7 @@ static int hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) {
+ }
+
+ ZEND_FUNCTION(eval_blacklist_callback) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+ const char* current_function_name = get_active_function_name(TSRMLS_C);
+ zend_string* tmp =
+ zend_string_init(current_function_name, strlen(current_function_name), 0);
+diff --git a/src/sp_harden_rand.c b/src/sp_harden_rand.c
+index 7b4e958..7ab798e 100644
+--- a/src/sp_harden_rand.c
++++ b/src/sp_harden_rand.c
+@@ -52,7 +52,7 @@ static void random_int_wrapper(INTERNAL_FUNCTION_PARAMETERS) {
+ }
+
+ PHP_FUNCTION(sp_rand) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+
+ /* call the original `rand` function,
+ * since we might no be the only ones to hook it*/
+@@ -64,7 +64,7 @@ PHP_FUNCTION(sp_rand) {
+ }
+
+ PHP_FUNCTION(sp_mt_rand) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+
+ /* call the original `mt_rand` function,
+ * since we might no be the only ones to hook it*/
+diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c
+index 5b36026..ac0cb8a 100644
+--- a/src/sp_sloppy.c
++++ b/src/sp_sloppy.c
+@@ -38,8 +38,8 @@ ZEND_API zend_op_array* sp_compile_file(zend_file_handle* file_handle,
+
+ static void array_handler(INTERNAL_FUNCTION_PARAMETERS,
+ const char *name, size_t size,
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS)) {
+- void (*handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler) {
++ zif_handler handler;
+ zval func_name;
+ zval params[3];
+ zval *value, *array;
+diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c
+index ab0139a..fb44ce4 100644
+--- a/src/sp_unserialize.c
++++ b/src/sp_unserialize.c
+@@ -3,7 +3,7 @@
+ ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus)
+
+ PHP_FUNCTION(sp_serialize) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+
+ /* Call the original `serialize` function. */
+ orig_handler = zend_hash_str_find_ptr(
+@@ -42,7 +42,7 @@ PHP_FUNCTION(sp_serialize) {
+ }
+
+ PHP_FUNCTION(sp_unserialize) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+
+ char *buf = NULL;
+ char *serialized_str = NULL;
+diff --git a/src/sp_utils.c b/src/sp_utils.c
+index 970f314..abb138b 100644
+--- a/src/sp_utils.c
++++ b/src/sp_utils.c
+@@ -320,7 +320,7 @@ bool sp_match_array_value(const zval* arr, const zend_string* to_match,
+ }
+
+ int hook_function(const char* original_name, HashTable* hook_table,
+- void (*new_function)(INTERNAL_FUNCTION_PARAMETERS)) {
++ zif_handler new_function) {
+ zend_internal_function* func;
+ bool ret = FAILURE;
+
+@@ -363,7 +363,7 @@ int hook_function(const char* original_name, HashTable* hook_table,
+ }
+
+ int hook_regexp(const sp_pcre* regexp, HashTable* hook_table,
+- void (*new_function)(INTERNAL_FUNCTION_PARAMETERS)) {
++ zif_handler new_function) {
+ zend_string* key;
+
+ ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key)
+diff --git a/src/sp_utils.h b/src/sp_utils.h
+index c094fac..d835905 100644
+--- a/src/sp_utils.h
++++ b/src/sp_utils.h
+@@ -54,10 +54,8 @@ void sp_log_disable(const char *restrict, const char *restrict,
+ const zend_string *restrict, const sp_disabled_function *);
+ void sp_log_disable_ret(const char *restrict, const zend_string *restrict,
+ const sp_disabled_function *);
+-int hook_function(const char *, HashTable *,
+- void (*)(INTERNAL_FUNCTION_PARAMETERS));
+-int hook_regexp(const sp_pcre *, HashTable *,
+- void (*)(INTERNAL_FUNCTION_PARAMETERS));
++int hook_function(const char *, HashTable *, zif_handler);
++int hook_regexp(const sp_pcre *, HashTable *, zif_handler);
+ bool check_is_in_eval_whitelist(const zend_string *const function_name);
+ int sp_log_request(const zend_string *folder, const zend_string *text_repr,
+ char *from);
+diff --git a/src/sp_wrapper.c b/src/sp_wrapper.c
+index d9cd296..3090513 100644
+--- a/src/sp_wrapper.c
++++ b/src/sp_wrapper.c
+@@ -45,7 +45,7 @@ void sp_disable_wrapper() {
+ }
+
+ PHP_FUNCTION(sp_stream_wrapper_register) {
+- void (*orig_handler)(INTERNAL_FUNCTION_PARAMETERS);
++ zif_handler orig_handler;
+ zend_string *protocol_name = NULL;
+
+ ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_QUIET, 2, EX_NUM_ARGS());
+
+From 70679f073f49dade464fedc9feaa6040107a1f48 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Mon, 3 Sep 2018 15:15:35 +0200
+Subject: [PATCH 2/2] fix -Wformat build warning
+
+---
+ src/sp_utils.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sp_utils.c b/src/sp_utils.c
+index abb138b..8a3874c 100644
+--- a/src/sp_utils.c
++++ b/src/sp_utils.c
+@@ -287,7 +287,7 @@ bool sp_match_array_key(const zval* zv, const zend_string* to_match,
+ }
+ } else {
+ char* idx_str = NULL;
+- spprintf(&idx_str, 0, "%lu", idx);
++ spprintf(&idx_str, 0, ZEND_ULONG_FMT, idx);
+ zend_string* tmp = zend_string_init(idx_str, strlen(idx_str), 0);
+ if (sp_match_value(tmp, to_match, rx)) {
+ efree(idx_str);
diff --git a/php-snuffleupagus.spec b/php-snuffleupagus.spec
index bc44d07..724c9d5 100644
--- a/php-snuffleupagus.spec
+++ b/php-snuffleupagus.spec
@@ -35,19 +35,23 @@ Version: 0.4.0
%if 0%{?gh_date}
Release: 1%{gh_date}.%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
%else
-Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
+Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}}
%endif
License: LGPLv3
Group: Development/Languages
URL: https://github.com/%{gh_owner}/%{gh_project}
Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pkg_name}-%{version}-%{gh_short}.tar.gz
+Patch0: https://patch-diff.githubusercontent.com/raw/nbs-system/snuffleupagus/pull/242.patch
+
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel > 7
BuildRequires: pcre-devel
# For tests/upload_validation_real.phpt
BuildRequires: %{_root_bindir}/python
BuildRequires: %{?scl_prefix}php-vld
+#BuildRequires: gdb
+#BuildRequires: php-debuginfo
Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api}
Requires: %{?scl_prefix}php(api) = %{php_core_api}
@@ -90,6 +94,7 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO
%prep
%setup -q -n %{gh_project}-%{gh_commit}
+%patch0 -p1 -b .pr242
cd src
# Sanity check, really often broken
@@ -175,7 +180,7 @@ cd src
: Upstream test suite for NTS extension
TEST_PHP_EXECUTABLE=%{__php} \
-TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \
+TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \
NO_INTERACTION=1 \
REPORT_EXIT_STATUS=1 \
%{__php} -n run-tests.php --show-diff
@@ -184,7 +189,7 @@ REPORT_EXIT_STATUS=1 \
cd ../ZTS
: Minimal load test for ZTS extension
%{__ztsphp} --no-php-ini \
- --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \
+ --define extension=$PWD/modules/%{pecl_name}.so \
--define sp.allow_broken_configuration=1 \
--modules | grep %{pecl_name}
@@ -213,6 +218,10 @@ REPORT_EXIT_STATUS=1 \
%changelog
+* Mon Sep 3 2018 Remi Collet <remi@remirepo.net> - 0.4.0-2
+- add patch for PHP 7.3 on 32-bit from
+ https://github.com/nbs-system/snuffleupagus/pull/242
+
* Sat Sep 1 2018 Remi Collet <remi@remirepo.net> - 0.4.0-1
- update to 0.4.0
- open https://github.com/nbs-system/snuffleupagus/issues/236