Skip to content

Commit d6bc266

Browse files
eriklaxbukka
authored andcommitted
Fix bug #76296 (openssl_pkey_get_public does not respect open_basedir)
1 parent b242925 commit d6bc266

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/openssl/openssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3785,6 +3785,9 @@ static EVP_PKEY * php_openssl_evp_from_zval(
37853785

37863786
if (Z_STRLEN_P(val) > 7 && memcmp(Z_STRVAL_P(val), "file://", sizeof("file://") - 1) == 0) {
37873787
filename = Z_STRVAL_P(val) + (sizeof("file://") - 1);
3788+
if (php_openssl_open_base_dir_chk(filename)) {
3789+
TMP_CLEAN;
3790+
}
37883791
}
37893792
/* it's an X509 file/cert of some kind, and we need to extract the data from that */
37903793
if (public_key) {
@@ -3811,9 +3814,6 @@ static EVP_PKEY * php_openssl_evp_from_zval(
38113814
BIO *in;
38123815

38133816
if (filename) {
3814-
if (php_openssl_open_base_dir_chk(filename)) {
3815-
TMP_CLEAN;
3816-
}
38173817
in = BIO_new_file(filename, PHP_OPENSSL_BIO_MODE_R(PKCS7_BINARY));
38183818
} else {
38193819
in = BIO_new_mem_buf(Z_STRVAL_P(val), (int)Z_STRLEN_P(val));

0 commit comments

Comments
 (0)