From 0242ae498e8e716937c14c59f05c1119501a7c28 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 4 Feb 2005 14:28:50 +0000 Subject: [PATCH] - Fixed bug #31754 (dbase_open() fails for mode = 1). (Mehdi, Derick) --- ext/dbase/dbase.c | 5 +++++ ext/dbase/tests/bug31754.phpt | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 ext/dbase/tests/bug31754.phpt diff --git a/ext/dbase/dbase.c b/ext/dbase/dbase.c index 5bb109de84e..15d9f4f00ea 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 00000000000..32f802b57bb --- /dev/null +++ b/ext/dbase/tests/bug31754.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #31754: (dbase_open() fails for mode = 1) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: dbase_open(): Cannot open /tmp/bug31754.dbf in write-only mode in %sbug31754.php on line %d