|
|
|
@ -179,17 +179,6 @@ static void php_csr_free(zend_rsrc_list_entry *rsrc TSRMLS_DC) |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ openssl open_basedir checks */ |
|
|
|
inline static int php_openssl_safe_mode_chk(char *filename TSRMLS_DC) |
|
|
|
{ |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
/* }}} */ |
|
|
|
|
|
|
|
/* {{{ openssl -> PHP "bridging" */ |
|
|
|
/* true global; readonly after module startup */ |
|
|
|
static char default_ssl_conf_filename[MAXPATHLEN]; |
|
|
|
@ -439,7 +428,7 @@ static int php_openssl_parse_config( |
|
|
|
|
|
|
|
/* read in the oids */ |
|
|
|
str = CONF_get_string(req->req_config, NULL, "oid_file"); |
|
|
|
if (str && !php_openssl_safe_mode_chk(str TSRMLS_CC)) { |
|
|
|
if (str && !php_check_open_basedir(str TSRMLS_CC)) { |
|
|
|
BIO *oid_bio = BIO_new_file(str, "r"); |
|
|
|
if (oid_bio) { |
|
|
|
OBJ_create_objects(oid_bio); |
|
|
|
@ -748,7 +737,7 @@ static X509 * php_openssl_x509_from_zval(zval ** val, int makeresource, long * r |
|
|
|
/* read cert from the named file */ |
|
|
|
BIO *in; |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(Z_STRVAL_PP(val) + (sizeof("file://") - 1) TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(Z_STRVAL_PP(val) + (sizeof("file://") - 1) TSRMLS_CC)) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
@ -800,7 +789,7 @@ PHP_FUNCTION(openssl_x509_export_to_file) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1000,7 +989,7 @@ static STACK_OF(X509) * load_all_certs_from_file(char *certfile) |
|
|
|
goto end; |
|
|
|
} |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(certfile TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(certfile TSRMLS_CC)) { |
|
|
|
goto end; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1400,7 +1389,7 @@ static X509_REQ * php_openssl_csr_from_zval(zval ** val, int makeresource, long |
|
|
|
filename = Z_STRVAL_PP(val) + (sizeof("file://") - 1); |
|
|
|
} |
|
|
|
if (filename) { |
|
|
|
if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
in = BIO_new_file(filename, "r"); |
|
|
|
@ -1436,7 +1425,7 @@ PHP_FUNCTION(openssl_csr_export_to_file) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -1833,7 +1822,7 @@ static EVP_PKEY * php_openssl_evp_from_zval(zval ** val, int public_key, char * |
|
|
|
BIO *in; |
|
|
|
|
|
|
|
if (filename) { |
|
|
|
if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
in = BIO_new_file(filename, "r"); |
|
|
|
@ -2002,7 +1991,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file) |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
RETURN_FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2188,7 +2177,7 @@ PHP_FUNCTION(openssl_pkcs7_verify) |
|
|
|
if (!store) { |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
if (php_openssl_safe_mode_chk(filename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(filename TSRMLS_CC)) { |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2206,7 +2195,7 @@ PHP_FUNCTION(openssl_pkcs7_verify) |
|
|
|
|
|
|
|
if (datafilename) { |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(datafilename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(datafilename TSRMLS_CC)) { |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2226,7 +2215,7 @@ PHP_FUNCTION(openssl_pkcs7_verify) |
|
|
|
if (signersfilename) { |
|
|
|
BIO *certout; |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(signersfilename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(signersfilename TSRMLS_CC)) { |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2286,7 +2275,7 @@ PHP_FUNCTION(openssl_pkcs7_encrypt) |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(infilename TSRMLS_CC) || php_openssl_safe_mode_chk(outfilename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(infilename TSRMLS_CC) || php_check_open_basedir(outfilename TSRMLS_CC)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2463,7 +2452,7 @@ PHP_FUNCTION(openssl_pkcs7_sign) |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(infilename TSRMLS_CC) || php_openssl_safe_mode_chk(outfilename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(infilename TSRMLS_CC) || php_check_open_basedir(outfilename TSRMLS_CC)) { |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
@ -2557,7 +2546,7 @@ PHP_FUNCTION(openssl_pkcs7_decrypt) |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
if (php_openssl_safe_mode_chk(infilename TSRMLS_CC) || php_openssl_safe_mode_chk(outfilename TSRMLS_CC)) { |
|
|
|
if (php_check_open_basedir(infilename TSRMLS_CC) || php_check_open_basedir(outfilename TSRMLS_CC)) { |
|
|
|
goto clean_exit; |
|
|
|
} |
|
|
|
|
|
|
|
|