From 0bd0337ef36f84bc9ed0dff0f3d7a855df373711 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 25 Sep 2024 15:13:44 +0200 Subject: fix build with PHP 8.4 using patch from https://github.com/bukka/php-crypto/pull/42 --- 0001-Fix-Wincompatible-pointer-types.patch | 50 +++++++++++++++++++++++ 0001-fix-for-PHP-8.4.patch | 64 ++++++++++++++++++++++++++++++ PHPINFO | 7 ++++ php-pecl-crypto.spec | 58 +++++++++++++-------------- 4 files changed, 149 insertions(+), 30 deletions(-) create mode 100644 0001-Fix-Wincompatible-pointer-types.patch create mode 100644 0001-fix-for-PHP-8.4.patch create mode 100644 PHPINFO diff --git a/0001-Fix-Wincompatible-pointer-types.patch b/0001-Fix-Wincompatible-pointer-types.patch new file mode 100644 index 0000000..2c2fa40 --- /dev/null +++ b/0001-Fix-Wincompatible-pointer-types.patch @@ -0,0 +1,50 @@ +From 3b841b78f00acbd8bef95d8ebcd0fefe9a0f0bfa Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Fri, 16 Feb 2024 15:58:45 +0100 +Subject: [PATCH] Fix [-Wincompatible-pointer-types] + +--- + crypto_stream.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/crypto_stream.c b/crypto_stream.c +index 4e0758c..f208b34 100644 +--- a/crypto_stream.c ++++ b/crypto_stream.c +@@ -133,13 +133,21 @@ typedef struct { + } php_crypto_stream_data; + + /* {{{ php_crypto_stream_write */ ++#if PHP_VERSION_ID < 70400 + static size_t php_crypto_stream_write(php_stream *stream, ++#else ++static ssize_t php_crypto_stream_write(php_stream *stream, ++#endif + const char *buf, size_t count TSRMLS_DC) + { + php_crypto_stream_data *data = (php_crypto_stream_data *) stream->abstract; + int bytes_written = BIO_write(data->bio, buf, count > INT_MAX ? INT_MAX : count); + ++#if PHP_VERSION_ID < 70400 + return bytes_written <= 0 ? 0 : (size_t) bytes_written; ++#else ++ return bytes_written; ++#endif + } + /* }}} */ + +@@ -256,7 +264,11 @@ static void php_crypto_stream_auth_save_result(php_stream *stream, int ok) + /* }}} */ + + /* {{{ php_crypto_stream_read */ ++#if PHP_VERSION_ID < 70400 + static size_t php_crypto_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) ++#else ++static ssize_t php_crypto_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC) ++#endif + { + php_crypto_stream_data *data = (php_crypto_stream_data *) stream->abstract; + int bytes_read = BIO_read(data->bio, buf, count > INT_MAX ? INT_MAX : count); +-- +2.43.0 + diff --git a/0001-fix-for-PHP-8.4.patch b/0001-fix-for-PHP-8.4.patch new file mode 100644 index 0000000..89eb499 --- /dev/null +++ b/0001-fix-for-PHP-8.4.patch @@ -0,0 +1,64 @@ +From 6137150915431a59edb993a008eb3b21fc2d02e0 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 25 Sep 2024 15:06:03 +0200 +Subject: [PATCH] fix for PHP 8.4 + +--- + crypto_cipher.c | 12 ++++++++++++ + crypto_hash.c | 4 ++++ + 2 files changed, 16 insertions(+) + +diff --git a/crypto_cipher.c b/crypto_cipher.c +index a0465c1..fb3e410 100644 +--- a/crypto_cipher.c ++++ b/crypto_cipher.c +@@ -497,7 +497,11 @@ PHP_MINIT_FUNCTION(crypto_cipher) + static inline void php_crypto_cipher_set_algorithm_name(zval *object, + char *algorithm, phpc_str_size_t algorithm_len TSRMLS_DC) + { ++#if PHP_VERSION_ID < 80400 + php_strtoupper(algorithm, algorithm_len); ++#else ++ zend_str_toupper(algorithm, algorithm_len); ++#endif + zend_update_property_stringl(php_crypto_cipher_ce, PHPC_OBJ_FOR_PROP(object), + "algorithm", sizeof("algorithm")-1, algorithm, algorithm_len TSRMLS_CC); + } +@@ -513,10 +517,18 @@ PHP_CRYPTO_API const EVP_CIPHER *php_crypto_get_cipher_algorithm( + return NULL; + } + ++#if PHP_VERSION_ID < 80400 + php_strtoupper(algorithm, algorithm_len); ++#else ++ zend_str_toupper(algorithm, algorithm_len); ++#endif + cipher = EVP_get_cipherbyname(algorithm); + if (!cipher) { ++#if PHP_VERSION_ID < 80400 + php_strtolower(algorithm, algorithm_len); ++#else ++ zend_str_tolower(algorithm, algorithm_len); ++#endif + cipher = EVP_get_cipherbyname(algorithm); + } + return cipher; +diff --git a/crypto_hash.c b/crypto_hash.c +index 8015aa4..9c4f182 100644 +--- a/crypto_hash.c ++++ b/crypto_hash.c +@@ -319,7 +319,11 @@ PHP_MINIT_FUNCTION(crypto_hash) + static inline void php_crypto_hash_set_algorithm_name(zval *object, + char *algorithm, phpc_str_size_t algorithm_len TSRMLS_DC) + { ++#if PHP_VERSION_ID < 80400 + php_strtoupper(algorithm, algorithm_len); ++#else ++ zend_str_toupper(algorithm, algorithm_len); ++#endif + zend_update_property_stringl(php_crypto_hash_ce, PHPC_OBJ_FOR_PROP(object), + "algorithm", sizeof("algorithm")-1, algorithm, algorithm_len TSRMLS_CC); + } +-- +2.46.1 + diff --git a/PHPINFO b/PHPINFO new file mode 100644 index 0000000..ca789d1 --- /dev/null +++ b/PHPINFO @@ -0,0 +1,7 @@ + +crypto + +Crypto Support => enabled +Crypto Version => 0.3.2 +OpenSSL Library Version => OpenSSL 3.0.9 30 May 2023 +OpenSSL Header Version => OpenSSL 3.0.5 5 Jul 2022 diff --git a/php-pecl-crypto.spec b/php-pecl-crypto.spec index c82beed..d775069 100644 --- a/php-pecl-crypto.spec +++ b/php-pecl-crypto.spec @@ -1,6 +1,6 @@ # remirepo spec file for php-pecl-crypto # -# Copyright (c) 2013-2023 Remi Collet +# Copyright (c) 2013-2024 Remi Collet # License: CC-BY-SA-4.0 # http://creativecommons.org/licenses/by-sa/4.0/ # @@ -23,11 +23,14 @@ Summary: Wrapper for OpenSSL Crypto Library Name: %{?scl_prefix}php-pecl-%{pecl_name} Version: 0.3.2 -Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 4%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} License: PHP-3.01 URL: https://pecl.php.net/package/%{pecl_name} Source0: https://pecl.php.net/get/%{sources}.tgz +Patch0: 0001-Fix-Wincompatible-pointer-types.patch +Patch1: 0001-fix-for-PHP-8.4.patch + BuildRequires: make BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel @@ -55,10 +58,13 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO # Don't install/register tests sed -e 's/role="test"/role="src"/' \ - %{?_licensedir:-e '/LICENSE/s/role="doc"/role="src"/' } \ + -e '/LICENSE/s/role="doc"/role="src"/' \ -i package.xml cd %{sources} +%patch -P0 -p1 +%patch -P1 -p1 + # Sanity check, really often broken extver=$(sed -n '/#define PHP_CRYPTO_VERSION/{s/.* "//;s/".*$//;p}' php_crypto.h) if test "x${extver}" != "x%{version}%{?prever:-%{prever}}"; then @@ -84,26 +90,30 @@ EOF cd %{sources} %{__phpize} +[ -f Makefile.global ] && GLOBAL=Makefile.global || GLOBAL=build/Makefile.global +sed -e 's/INSTALL_ROOT/DESTDIR/' -i $GLOBAL cd ../NTS %configure \ --with-crypto \ --with-php-config=%{__phpconfig} -make %{?_smp_mflags} + +%make_build %if %{with_zts} cd ../ZTS %configure \ --with-crypto \ --with-php-config=%{__ztsphpconfig} -make %{?_smp_mflags} + +%make_build %endif %install %{?dtsenable} -make -C NTS install INSTALL_ROOT=%{buildroot} +%make_install -C NTS # install config file install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} @@ -112,7 +122,7 @@ install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml %if %{with_zts} -make -C ZTS install INSTALL_ROOT=%{buildroot} +%make_install -C ZTS install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name} %endif @@ -123,33 +133,13 @@ do install -Dpm 644 %{sources}/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i done -%if 0%{?fedora} < 24 && 0%{?rhel} < 8 -# when pear installed alone, after us -%triggerin -- %{?scl_prefix}php-pear -if [ -x %{__pecl} ] ; then - %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : -fi - -# posttrans as pear can be installed after us -%posttrans -if [ -x %{__pecl} ] ; then - %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : -fi - -%postun -if [ $1 -eq 0 -a -x %{__pecl} ] ; then - %{pecl_uninstall} %{pecl_name} >/dev/null || : -fi -%endif - - %check cd %{sources} : Minimal load test for NTS extension %{__php} --no-php-ini \ --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ - --modules | grep %{pecl_name} + --modules | grep '^%{pecl_name}$' %if %{with tests} : Upstream test suite for NTS extension @@ -163,7 +153,7 @@ REPORT_EXIT_STATUS=1 \ : Minimal load test for ZTS extension %{__ztsphp} --no-php-ini \ --define extension=%{buildroot}%{php_ztsextdir}//%{pecl_name}.so \ - --modules | grep %{pecl_name} + --modules | grep '^%{pecl_name}$' %if %{with tests} : Upstream test suite for ZTS extension @@ -176,7 +166,7 @@ REPORT_EXIT_STATUS=1 \ %files -%{?_licensedir:%license %{sources}/LICENSE} +%license %{sources}/LICENSE %doc %{pecl_docdir}/%{pecl_name} %{pecl_xmldir}/%{name}.xml %config(noreplace) %{php_inidir}/%{ini_name} @@ -190,6 +180,14 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Wed Sep 25 2024 Remi Collet - 0.3.2-4 +- fix build with PHP 8.4 using patch from + https://github.com/bukka/php-crypto/pull/42 + +* Fri Feb 16 2024 Remi Collet - 0.3.2-3 +- fix [-Wincompatible-pointer-types] using patch from + https://github.com/bukka/php-crypto/pull/40 + * Thu Aug 31 2023 Remi Collet - 0.3.2-2 - build out of sources tree -- cgit