- Fixed bug #31754 (dbase_open() fails for mode = 1). (Mehdi, Derick)

This commit is contained in:
Derick Rethans 2005-02-04 14:28:50 +00:00
parent b61a63d008
commit 0242ae498e
2 changed files with 31 additions and 0 deletions

View File

@ -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;
}

View 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