mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
- Fixed bug #31754 (dbase_open() fails for mode = 1). (Mehdi, Derick)
This commit is contained in:
parent
b61a63d008
commit
0242ae498e
@ -129,6 +129,11 @@ PHP_FUNCTION(dbase_open)
|
||||
convert_to_string_ex(dbf_name);
|
||||
convert_to_long_ex(options);
|
||||
|
||||
if (Z_LVAL_PP(options) == 1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_PP(dbf_name));
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
26
ext/dbase/tests/bug31754.phpt
Normal file
26
ext/dbase/tests/bug31754.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
Bug #31754: (dbase_open() fails for mode = 1)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dbase')) {
|
||||
die('skip dbase extension not available');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
// database "definition"
|
||||
$def = array(
|
||||
array("foo", "L")
|
||||
);
|
||||
|
||||
// creation
|
||||
$dbh = dbase_create('/tmp/bug31754.dbf', array(array('foo', 'L')));
|
||||
dbase_close($dbh);
|
||||
|
||||
$dbh = dbase_open('/tmp/bug31754.dbf', 1);
|
||||
unlink('/tmp/bug31754.dbf');
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: dbase_open(): Cannot open /tmp/bug31754.dbf in write-only mode in %sbug31754.php on line %d
|
Loading…
Reference in New Issue
Block a user