summaryrefslogtreecommitdiff
path: root/ext/dbase
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2005-02-04 14:28:50 +0000
committerDerick Rethans <derick@php.net>2005-02-04 14:28:50 +0000
commit0242ae498e8e716937c14c59f05c1119501a7c28 (patch)
tree023864be358df6adea6422cd8be557aea7cb2d70 /ext/dbase
parentb61a63d00875ffa9c59994c928a0606de1627714 (diff)
downloadphp-git-0242ae498e8e716937c14c59f05c1119501a7c28.tar.gz
- Fixed bug #31754 (dbase_open() fails for mode = 1). (Mehdi, Derick)
Diffstat (limited to 'ext/dbase')
-rw-r--r--ext/dbase/dbase.c5
-rw-r--r--ext/dbase/tests/bug31754.phpt26
2 files changed, 31 insertions, 0 deletions
diff --git a/ext/dbase/dbase.c b/ext/dbase/dbase.c
index 5bb109de84..15d9f4f00e 100644
--- a/ext/dbase/dbase.c
+++ b/ext/dbase/dbase.c
@@ -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;
}
diff --git a/ext/dbase/tests/bug31754.phpt b/ext/dbase/tests/bug31754.phpt
new file mode 100644
index 0000000000..32f802b57b
--- /dev/null
+++ b/ext/dbase/tests/bug31754.phpt
@@ -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