tony2001 Sun Feb 25 23:17:12 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/dbase dbase.c
/php-src/ext/dbase/tests 001.phpt
Log:
MFH: do not allow db without fields
http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.74.2.2.2.8&r2=1.74.2.2.2.9&diff_format=u
Index: php-src/ext/dbase/dbase.c
diff -u php-src/ext/dbase/dbase.c:1.74.2.2.2.8
php-src/ext/dbase/dbase.c:1.74.2.2.2.9
--- php-src/ext/dbase/dbase.c:1.74.2.2.2.8 Mon Jan 1 09:36:00 2007
+++ php-src/ext/dbase/dbase.c Sun Feb 25 23:17:12 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dbase.c,v 1.74.2.2.2.8 2007/01/01 09:36:00 sebastian Exp $ */
+/* $Id: dbase.c,v 1.74.2.2.2.9 2007/02/25 23:17:12 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -621,6 +621,11 @@
num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields));
+ if (num_fields <= 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create
database without fields");
+ RETURN_FALSE;
+ }
+
/* have to use regular malloc() because this gets free()d by
code in the dbase library */
dbh = (dbhead_t *)malloc(sizeof(dbhead_t));
http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/tests/001.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/dbase/tests/001.phpt
diff -u php-src/ext/dbase/tests/001.phpt:1.1.2.1
php-src/ext/dbase/tests/001.phpt:1.1.2.2
--- php-src/ext/dbase/tests/001.phpt:1.1.2.1 Wed Jul 12 13:08:38 2006
+++ php-src/ext/dbase/tests/001.phpt Sun Feb 25 23:17:12 2007
@@ -51,7 +51,9 @@
Warning: dbase_create(): expected field name as first element of list in field
0 in %s on line %d
bool(false)
-int(%d)
+
+Warning: dbase_create(): Unable to create database without fields in %s on
line %d
+bool(false)
Warning: dbase_create(): Expected array as second parameter in %s on line %d
bool(false)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php