[packages/php/PHP_5_6] Rel 42. Fix PLD patches: openssl_pkey_new() bn lookup and openssl_pkey_get_details() stack zvals (op

arekm arekm at pld-linux.org
Thu Oct 22 12:04:58 CEST 2026


commit 03af0058bd27ba4be67d530c5b96815dd2af90bb
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Thu Oct 22 11:24:54 2026 +0200

    Rel 42. Fix PLD patches: openssl_pkey_new() bn lookup and openssl_pkey_get_details() stack zvals (openssl.patch), uninitialised ibase timestamp (types.patch).

 openssl.patch | 85 +++++++++++++++++++++++++++++++----------------------------
 php.spec      |  2 +-
 types.patch   |  5 ++--
 3 files changed, 47 insertions(+), 45 deletions(-)
---
diff --git a/php.spec b/php.spec
index 5fa3612..6985ea8 100644
--- a/php.spec
+++ b/php.spec
@@ -155,7 +155,7 @@ ERROR: You need to select at least one Apache SAPI to build shared modules.
 %undefine	with_filter
 %endif
 
-%define		rel	41
+%define		rel	42
 %define		orgname	php
 %define		ver_suffix 56
 %define		php_suffix %{!?with_default_php:%{ver_suffix}}
diff --git a/openssl.patch b/openssl.patch
index 5edcaeb..55c4cbe 100644
--- a/openssl.patch
+++ b/openssl.patch
@@ -210,7 +210,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
 +		char *str = emalloc(len + 1); \
 +		BN_bn2bin(_bn, (unsigned char*)str); \
 +		str[len] = 0; \
-+		add_assoc_stringl(&_array, #_name, str, len, 0); \
++		add_assoc_stringl(_array, #_name, str, len, 0); \
 +	} \
 +} while (0);
 +
@@ -218,7 +218,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
 +
 +#define OPENSSL_PKEY_SET_BN(_data, _name) do { \
 +	zval **bn; \
-+	if (zend_hash_find(Z_ARRVAL_PP(_data), #_name, sizeof(#_name), (void**)bn) == SUCCESS && \
++	if (zend_hash_find(Z_ARRVAL_PP(_data), #_name, sizeof(#_name), (void**)&bn) == SUCCESS && \
 +			Z_TYPE_PP(bn) == IS_STRING) { \
 +		_name = BN_bin2bn( \
 +				(unsigned char*)Z_STRVAL_PP(bn), \
@@ -434,7 +434,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  #ifdef HAVE_EVP_PKEY_EC
  			case EVP_PKEY_EC:
  				pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned char *)passphrase, passphrase_len, NULL, NULL);
-@@ -3928,25 +4055,32 @@ PHP_FUNCTION(openssl_pkey_get_details)
+@@ -3928,25 +4055,33 @@ PHP_FUNCTION(openssl_pkey_get_details)
  	/*TODO: Use the real values once the openssl constants are used 
  	 * See the enum at the top of this file
  	 */
@@ -463,14 +463,15 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
 +				ktype = OPENSSL_KEYTYPE_RSA;
 +
 +				if (rsa != NULL) {
-+					zval z_rsa;
++					zval *z_rsa;
 +					const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp;
 +
 +					RSA_get0_key(rsa, &n, &e, &d);
 +					RSA_get0_factors(rsa, &p, &q);
 +					RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp);
 +
-+					array_init(&z_rsa);
++					ALLOC_INIT_ZVAL(z_rsa);
++					array_init(z_rsa);
 +					OPENSSL_PKEY_GET_BN(z_rsa, n);
 +					OPENSSL_PKEY_GET_BN(z_rsa, e);
 +					OPENSSL_PKEY_GET_BN(z_rsa, d);
@@ -479,12 +480,12 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
 +					OPENSSL_PKEY_GET_BN(z_rsa, dmp1);
 +					OPENSSL_PKEY_GET_BN(z_rsa, dmq1);
 +					OPENSSL_PKEY_GET_BN(z_rsa, iqmp);
-+					add_assoc_zval(return_value, "rsa", &z_rsa);
++					add_assoc_zval(return_value, "rsa", z_rsa);
 +				}
  			}
  
  			break;	
-@@ -3954,42 +4088,53 @@ PHP_FUNCTION(openssl_pkey_get_details)
+@@ -3954,42 +4089,55 @@ PHP_FUNCTION(openssl_pkey_get_details)
  		case EVP_PKEY_DSA2:
  		case EVP_PKEY_DSA3:
  		case EVP_PKEY_DSA4:
@@ -506,19 +507,20 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
 +				ktype = OPENSSL_KEYTYPE_DSA;
 +
 +				if (dsa != NULL) {
-+					zval z_dsa;
++					zval *z_dsa;
 +					const BIGNUM *p, *q, *g, *priv_key, *pub_key;
 +
 +					DSA_get0_pqg(dsa, &p, &q, &g);
 +					DSA_get0_key(dsa, &pub_key, &priv_key);
 +
-+					array_init(&z_dsa);
++					ALLOC_INIT_ZVAL(z_dsa);
++					array_init(z_dsa);
 +					OPENSSL_PKEY_GET_BN(z_dsa, p);
 +					OPENSSL_PKEY_GET_BN(z_dsa, q);
 +					OPENSSL_PKEY_GET_BN(z_dsa, g);
 +					OPENSSL_PKEY_GET_BN(z_dsa, priv_key);
 +					OPENSSL_PKEY_GET_BN(z_dsa, pub_key);
-+					add_assoc_zval(return_value, "dsa", &z_dsa);
++					add_assoc_zval(return_value, "dsa", z_dsa);
 +				}
  			}
  			break;
@@ -541,18 +543,19 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
 +				ktype = OPENSSL_KEYTYPE_DH;
 +
 +				if (dh != NULL) {
-+					zval z_dh;
++					zval *z_dh;
 +					const BIGNUM *p, *q, *g, *priv_key, *pub_key;
 +
 +					DH_get0_pqg(dh, &p, &q, &g);
 +					DH_get0_key(dh, &pub_key, &priv_key);
 +
-+					array_init(&z_dh);
++					ALLOC_INIT_ZVAL(z_dh);
++					array_init(z_dh);
 +					OPENSSL_PKEY_GET_BN(z_dh, p);
 +					OPENSSL_PKEY_GET_BN(z_dh, g);
 +					OPENSSL_PKEY_GET_BN(z_dh, priv_key);
 +					OPENSSL_PKEY_GET_BN(z_dh, pub_key);
-+					add_assoc_zval(return_value, "dh", &z_dh);
++					add_assoc_zval(return_value, "dh", z_dh);
 +				}
  			}
  
@@ -565,7 +568,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  				zval *ec;
  				const EC_GROUP *ec_group;
  				int nid;
-@@ -4546,13 +4691,13 @@ PHP_FUNCTION(openssl_private_encrypt)
+@@ -4546,13 +4694,13 @@ PHP_FUNCTION(openssl_private_encrypt)
  	cryptedlen = EVP_PKEY_size(pkey);
  	cryptedbuf = emalloc(cryptedlen + 1);
  
@@ -581,7 +584,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  						padding) == cryptedlen);
  			break;
  		default:
-@@ -4604,13 +4749,13 @@ PHP_FUNCTION(openssl_private_decrypt)
+@@ -4604,13 +4752,13 @@ PHP_FUNCTION(openssl_private_decrypt)
  	cryptedlen = EVP_PKEY_size(pkey);
  	crypttemp = emalloc(cryptedlen + 1);
  
@@ -597,7 +600,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  					padding);
  			if (cryptedlen != -1) {
  				cryptedbuf = emalloc(cryptedlen + 1);
-@@ -4669,13 +4814,13 @@ PHP_FUNCTION(openssl_public_encrypt)
+@@ -4669,13 +4817,13 @@ PHP_FUNCTION(openssl_public_encrypt)
  	cryptedlen = EVP_PKEY_size(pkey);
  	cryptedbuf = emalloc(cryptedlen + 1);
  
@@ -614,7 +617,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  						padding) == cryptedlen);
  			break;
  		default:
-@@ -4728,13 +4873,13 @@ PHP_FUNCTION(openssl_public_decrypt)
+@@ -4728,13 +4876,13 @@ PHP_FUNCTION(openssl_public_decrypt)
  	cryptedlen = EVP_PKEY_size(pkey);
  	crypttemp = emalloc(cryptedlen + 1);
  
@@ -631,7 +634,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  					padding);
  			if (cryptedlen != -1) {
  				cryptedbuf = emalloc(cryptedlen + 1);
-@@ -4798,7 +4943,7 @@ PHP_FUNCTION(openssl_sign)
+@@ -4798,7 +4946,7 @@ PHP_FUNCTION(openssl_sign)
  	long keyresource = -1;
  	char * data;
  	int data_len;
@@ -640,7 +643,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	zval *method = NULL;
  	long signature_algo = OPENSSL_ALGO_SHA1;
  	const EVP_MD *mdtype;
-@@ -4831,9 +4976,11 @@ PHP_FUNCTION(openssl_sign)
+@@ -4831,9 +4979,11 @@ PHP_FUNCTION(openssl_sign)
  	siglen = EVP_PKEY_size(pkey);
  	sigbuf = emalloc(siglen + 1);
  
@@ -655,7 +658,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  		zval_dtor(signature);
  		sigbuf[siglen] = '\0';
  		ZVAL_STRINGL(signature, (char *)sigbuf, siglen, 0);
-@@ -4842,7 +4989,7 @@ PHP_FUNCTION(openssl_sign)
+@@ -4842,7 +4992,7 @@ PHP_FUNCTION(openssl_sign)
  		efree(sigbuf);
  		RETVAL_FALSE;
  	}
@@ -664,7 +667,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	if (keyresource == -1) {
  		EVP_PKEY_free(pkey);
  	}
-@@ -4855,8 +5002,8 @@ PHP_FUNCTION(openssl_verify)
+@@ -4855,8 +5005,8 @@ PHP_FUNCTION(openssl_verify)
  {
  	zval **key;
  	EVP_PKEY *pkey;
@@ -675,7 +678,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	const EVP_MD *mdtype;
  	long keyresource = -1;
  	char * data;	int data_len;
-@@ -4890,10 +5037,13 @@ PHP_FUNCTION(openssl_verify)
+@@ -4890,10 +5040,13 @@ PHP_FUNCTION(openssl_verify)
  		RETURN_FALSE;
  	}
  
@@ -693,7 +696,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  
  	if (keyresource == -1) {
  		EVP_PKEY_free(pkey);
-@@ -4917,7 +5067,7 @@ PHP_FUNCTION(openssl_seal)
+@@ -4917,7 +5070,7 @@ PHP_FUNCTION(openssl_seal)
  	char *method =NULL;
  	int method_len = 0;
  	const EVP_CIPHER *cipher;
@@ -702,7 +705,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  
  	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szza/|s", &data, &data_len, &sealdata, &ekeys, &pubkeys, &method, &method_len) == FAILURE) {
  		return;
-@@ -4968,9 +5118,10 @@ PHP_FUNCTION(openssl_seal)
+@@ -4968,9 +5121,10 @@ PHP_FUNCTION(openssl_seal)
  		i++;
  	}
  
@@ -715,7 +718,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  		goto clean_exit;
  	}
  
-@@ -4980,15 +5131,15 @@ PHP_FUNCTION(openssl_seal)
+@@ -4980,15 +5134,15 @@ PHP_FUNCTION(openssl_seal)
  	iv = ivlen ? emalloc(ivlen + 1) : NULL;
  #endif
  	/* allocate one byte extra to make room for \0 */
@@ -737,7 +740,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  		goto clean_exit;
  	}
  
-@@ -5019,7 +5170,7 @@ PHP_FUNCTION(openssl_seal)
+@@ -5019,7 +5173,7 @@ PHP_FUNCTION(openssl_seal)
  		efree(buf);
  	}
  	RETVAL_LONG(len1 + len2);
@@ -746,7 +749,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  
  clean_exit:
  	for (i=0; i<nkeys; i++) {
-@@ -5046,7 +5197,7 @@ PHP_FUNCTION(openssl_open)
+@@ -5046,7 +5200,7 @@ PHP_FUNCTION(openssl_open)
  	int len1, len2;
  	unsigned char *buf;
  	long keyresource = -1;
@@ -755,7 +758,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	char * data;	int data_len;
  	char * ekey;	int ekey_len;
  	char *method =NULL;
-@@ -5072,27 +5223,26 @@ PHP_FUNCTION(openssl_open)
+@@ -5072,27 +5226,26 @@ PHP_FUNCTION(openssl_open)
  	} else {
  		cipher = EVP_rc4();
  	}
@@ -795,7 +798,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  }
  /* }}} */
  
-@@ -5152,7 +5302,7 @@ PHP_FUNCTION(openssl_digest)
+@@ -5152,7 +5305,7 @@ PHP_FUNCTION(openssl_digest)
  	char *data, *method;
  	int data_len, method_len;
  	const EVP_MD *mdtype;
@@ -804,7 +807,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	int siglen;
  	unsigned char *sigbuf;
  
-@@ -5168,9 +5318,10 @@ PHP_FUNCTION(openssl_digest)
+@@ -5168,9 +5321,10 @@ PHP_FUNCTION(openssl_digest)
  	siglen = EVP_MD_size(mdtype);
  	sigbuf = emalloc(siglen + 1);
  
@@ -818,7 +821,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  		if (raw_output) {
  			sigbuf[siglen] = '\0';
  			RETVAL_STRINGL((char *)sigbuf, siglen, 0);
-@@ -5186,6 +5337,8 @@ PHP_FUNCTION(openssl_digest)
+@@ -5186,6 +5340,8 @@ PHP_FUNCTION(openssl_digest)
  		efree(sigbuf);
  		RETVAL_FALSE;
  	}
@@ -827,7 +830,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  }
  /* }}} */
  
-@@ -5231,7 +5384,7 @@ PHP_FUNCTION(openssl_encrypt)
+@@ -5231,7 +5387,7 @@ PHP_FUNCTION(openssl_encrypt)
  	char *data, *method, *password, *iv = "";
  	int data_len, method_len, password_len, iv_len = 0, max_iv_len;
  	const EVP_CIPHER *cipher_type;
@@ -836,7 +839,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	int i=0, outlen, keylen;
  	unsigned char *outbuf, *key;
  	zend_bool free_iv;
-@@ -5245,6 +5398,12 @@ PHP_FUNCTION(openssl_encrypt)
+@@ -5245,6 +5401,12 @@ PHP_FUNCTION(openssl_encrypt)
  		RETURN_FALSE;
  	}
  
@@ -849,7 +852,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	keylen = EVP_CIPHER_key_length(cipher_type);
  	if (keylen > password_len) {
  		key = emalloc(keylen);
-@@ -5263,19 +5422,19 @@ PHP_FUNCTION(openssl_encrypt)
+@@ -5263,19 +5425,19 @@ PHP_FUNCTION(openssl_encrypt)
  	outlen = data_len + EVP_CIPHER_block_size(cipher_type);
  	outbuf = safe_emalloc(outlen, 1, 1);
  
@@ -875,7 +878,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  		outlen += i;
  		if (options & OPENSSL_RAW_DATA) {
  			outbuf[outlen] = '\0';
-@@ -5302,7 +5461,7 @@ PHP_FUNCTION(openssl_encrypt)
+@@ -5302,7 +5464,7 @@ PHP_FUNCTION(openssl_encrypt)
  	if (free_iv) {
  		efree(iv);
  	}
@@ -884,7 +887,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  }
  /* }}} */
  
-@@ -5314,7 +5473,7 @@ PHP_FUNCTION(openssl_decrypt)
+@@ -5314,7 +5476,7 @@ PHP_FUNCTION(openssl_decrypt)
  	char *data, *method, *password, *iv = "";
  	int data_len, method_len, password_len, iv_len = 0;
  	const EVP_CIPHER *cipher_type;
@@ -893,7 +896,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	int i, outlen, keylen;
  	unsigned char *outbuf, *key;
  	int base64_str_len;
-@@ -5336,10 +5495,17 @@ PHP_FUNCTION(openssl_decrypt)
+@@ -5336,10 +5498,17 @@ PHP_FUNCTION(openssl_decrypt)
  		RETURN_FALSE;
  	}
  
@@ -911,7 +914,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  			RETURN_FALSE;
  		}
  		data_len = base64_str_len;
-@@ -5360,17 +5526,17 @@ PHP_FUNCTION(openssl_decrypt)
+@@ -5360,17 +5529,17 @@ PHP_FUNCTION(openssl_decrypt)
  	outlen = data_len + EVP_CIPHER_block_size(cipher_type);
  	outbuf = emalloc(outlen + 1);
  
@@ -935,7 +938,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  		outlen += i;
  		outbuf[outlen] = '\0';
  		RETVAL_STRINGL((char *)outbuf, outlen, 0);
-@@ -5387,7 +5553,7 @@ PHP_FUNCTION(openssl_decrypt)
+@@ -5387,7 +5556,7 @@ PHP_FUNCTION(openssl_decrypt)
  	if (base64_str) {
  		efree(base64_str);
  	}
@@ -944,7 +947,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  }
  /* }}} */
  
-@@ -5425,6 +5591,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
+@@ -5425,6 +5594,7 @@ PHP_FUNCTION(openssl_dh_compute_key)
  	zval *key;
  	char *pub_str;
  	int pub_len;
@@ -952,7 +955,7 @@ diff -urNp -x '*.orig' php-5.6.40.org/ext/openssl/openssl.c php-5.6.40/ext/opens
  	EVP_PKEY *pkey;
  	BIGNUM *pub;
  	char *data;
-@@ -5434,14 +5601,18 @@ PHP_FUNCTION(openssl_dh_compute_key)
+@@ -5434,14 +5604,18 @@ PHP_FUNCTION(openssl_dh_compute_key)
  		return;
  	}
  	ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, &key, -1, "OpenSSL key", le_key);
diff --git a/types.patch b/types.patch
index 3f1c503..245b32c 100644
--- a/types.patch
+++ b/types.patch
@@ -11,17 +11,16 @@
  
 --- php-7.3.33/ext/interbase/ibase_query.c.orig	2021-11-16 12:18:38.000000000 +0100
 +++ php-7.3.33/ext/interbase/ibase_query.c	2025-01-23 20:08:11.773054372 +0100
-@@ -695,10 +695,12 @@
+@@ -695,10 +695,11 @@
  			case SQL_TYPE_TIME:
  				if (Z_TYPE_P(b_var) == IS_LONG) {
  					struct tm *res;
 -					res = php_gmtime_r(&Z_LVAL_P(b_var), &t);
-+					time_t ts;
++					time_t ts = Z_LVAL_P(b_var);
 +					res = php_gmtime_r(&ts, &t);
  					if (!res) {
  						return FAILURE;
  					}
-+					Z_LVAL_P(b_var) = (long) ts;
  				} else {
  #ifdef HAVE_STRPTIME
  					char *format = INI_STR("ibase.timestampformat");
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php.git/commitdiff/03af0058bd27ba4be67d530c5b96815dd2af90bb



More information about the pld-cvs-commit mailing list