Fix parsing regression from PHP 7

This commit is contained in:
Christopher Jones 2020-09-08 15:48:48 +10:00
parent 8a49310f4e
commit 6134bf9ab1
2 changed files with 16 additions and 6 deletions

View file

@ -284,7 +284,7 @@ PHP_FUNCTION(oci_lob_import)
char *filename;
size_t filename_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
RETURN_THROWS();
}
@ -293,6 +293,11 @@ PHP_FUNCTION(oci_lob_import)
RETURN_FALSE;
}
if (CHECK_NULL_PATH(filename, filename_len)) {
php_error_docref(NULL, E_WARNING, "filename must not contain null bytes");
RETURN_FALSE;
}
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
if (php_oci_lob_import(descriptor, filename)) {
@ -835,7 +840,7 @@ PHP_FUNCTION(oci_lob_export)
php_stream *stream;
ub4 lob_length;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
RETURN_THROWS();
}
@ -864,6 +869,11 @@ PHP_FUNCTION(oci_lob_export)
RETURN_FALSE;
}
if (CHECK_NULL_PATH(filename, filename_len)) {
php_error_docref(NULL, E_WARNING, "filename must not contain null bytes");
RETURN_FALSE;
}
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
if (php_oci_lob_get_length(descriptor, &lob_length)) {

View file

@ -35,9 +35,9 @@ var_dump($r);
--EXPECTF--
Test 1: Import
Warning: OCILob::savefile(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d
NULL
Warning: OCILob::savefile(): filename must not contain null bytes in /Users/cjones/php-src/ext/oci8/tests/null_byte_1.php on line %d
bool(false)
Test 2: Export
Warning: OCILob::export(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d
NULL
Warning: OCILob::export(): filename must not contain null bytes in /Users/cjones/php-src/ext/oci8/tests/null_byte_1.php on line %d
bool(false)