Skip to content

Commit 0d7ce4c

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: openssl: Fix missing error propagation for BIO_printf() calls
2 parents 6932260 + f92d54b commit 0d7ce4c

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ PHP NEWS
2727
- OpenSSL:
2828
. Fixed bug GH-21083 (Skip private_key_bits validation for EC/curve-based
2929
keys). (iliaal)
30+
. Fix missing error propagation for BIO_printf() calls. (ndossche)
3031

3132
- PCNTL:
3233
. Fixed signal handler installation on AIX by bumping the storage size of the

ext/openssl/openssl.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,16 +2703,21 @@ PHP_FUNCTION(openssl_pkcs7_encrypt)
27032703
/* tack on extra headers */
27042704
if (zheaders) {
27052705
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zheaders), strindex, zcertval) {
2706+
int ret;
27062707
zend_string *str = zval_try_get_string(zcertval);
27072708
if (UNEXPECTED(!str)) {
27082709
goto clean_exit;
27092710
}
27102711
if (strindex) {
2711-
BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), ZSTR_VAL(str));
2712+
ret = BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), ZSTR_VAL(str));
27122713
} else {
2713-
BIO_printf(outfile, "%s\n", ZSTR_VAL(str));
2714+
ret = BIO_printf(outfile, "%s\n", ZSTR_VAL(str));
27142715
}
27152716
zend_string_release(str);
2717+
if (ret < 0) {
2718+
php_openssl_store_errors();
2719+
goto clean_exit;
2720+
}
27162721
} ZEND_HASH_FOREACH_END();
27172722
}
27182723

@@ -2932,6 +2937,7 @@ PHP_FUNCTION(openssl_pkcs7_sign)
29322937
zend_string_release(str);
29332938
if (ret < 0) {
29342939
php_openssl_store_errors();
2940+
goto clean_exit;
29352941
}
29362942
} ZEND_HASH_FOREACH_END();
29372943
}
@@ -3332,16 +3338,21 @@ PHP_FUNCTION(openssl_cms_encrypt)
33323338
/* tack on extra headers */
33333339
if (zheaders && encoding == ENCODING_SMIME) {
33343340
ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(zheaders), strindex, zcertval) {
3341+
int ret;
33353342
zend_string *str = zval_try_get_string(zcertval);
33363343
if (UNEXPECTED(!str)) {
33373344
goto clean_exit;
33383345
}
33393346
if (strindex) {
3340-
BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), ZSTR_VAL(str));
3347+
ret = BIO_printf(outfile, "%s: %s\n", ZSTR_VAL(strindex), ZSTR_VAL(str));
33413348
} else {
3342-
BIO_printf(outfile, "%s\n", ZSTR_VAL(str));
3349+
ret = BIO_printf(outfile, "%s\n", ZSTR_VAL(str));
33433350
}
33443351
zend_string_release(str);
3352+
if (ret < 0) {
3353+
php_openssl_store_errors();
3354+
goto clean_exit;
3355+
}
33453356
} ZEND_HASH_FOREACH_END();
33463357
}
33473358

@@ -3622,6 +3633,7 @@ PHP_FUNCTION(openssl_cms_sign)
36223633
zend_string_release(str);
36233634
if (ret < 0) {
36243635
php_openssl_store_errors();
3636+
goto clean_exit;
36253637
}
36263638
} ZEND_HASH_FOREACH_END();
36273639
}

0 commit comments

Comments
 (0)