Skip to content

Commit 6134bf9

Browse files
committed
Fix parsing regression from PHP 7
1 parent 8a49310 commit 6134bf9

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

ext/oci8/oci8_interface.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ PHP_FUNCTION(oci_lob_import)
284284
char *filename;
285285
size_t filename_len;
286286

287-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
287+
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
288288
RETURN_THROWS();
289289
}
290290

@@ -293,6 +293,11 @@ PHP_FUNCTION(oci_lob_import)
293293
RETURN_FALSE;
294294
}
295295

296+
if (CHECK_NULL_PATH(filename, filename_len)) {
297+
php_error_docref(NULL, E_WARNING, "filename must not contain null bytes");
298+
RETURN_FALSE;
299+
}
300+
296301
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
297302

298303
if (php_oci_lob_import(descriptor, filename)) {
@@ -835,7 +840,7 @@ PHP_FUNCTION(oci_lob_export)
835840
php_stream *stream;
836841
ub4 lob_length;
837842

838-
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
843+
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|ll", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &length) == FAILURE) {
839844
RETURN_THROWS();
840845
}
841846

@@ -864,6 +869,11 @@ PHP_FUNCTION(oci_lob_export)
864869
RETURN_FALSE;
865870
}
866871

872+
if (CHECK_NULL_PATH(filename, filename_len)) {
873+
php_error_docref(NULL, E_WARNING, "filename must not contain null bytes");
874+
RETURN_FALSE;
875+
}
876+
867877
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
868878

869879
if (php_oci_lob_get_length(descriptor, &lob_length)) {

ext/oci8/tests/null_byte_1.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ var_dump($r);
3535
--EXPECTF--
3636
Test 1: Import
3737

38-
Warning: OCILob::savefile(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d
39-
NULL
38+
Warning: OCILob::savefile(): filename must not contain null bytes in /Users/cjones/php-src/ext/oci8/tests/null_byte_1.php on line %d
39+
bool(false)
4040
Test 2: Export
4141

42-
Warning: OCILob::export(): Argument #1 ($function) must be a valid path, string given in %snull_byte_1.php on line %d
43-
NULL
42+
Warning: OCILob::export(): filename must not contain null bytes in /Users/cjones/php-src/ext/oci8/tests/null_byte_1.php on line %d
43+
bool(false)

0 commit comments

Comments
 (0)