felipe          Tue Oct  7 15:31:48 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/interbase/tests        bug46247.phpt 

  Modified files:              
    /php-src    NEWS 
    /php-src/ext/interbase      ibase_events.c 
  Log:
  - MFH: Fixed bug #46247 (ibase_set_event_handler() is allowing to pass 
callback without event)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1244&r2=1.2027.2.547.2.1245&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1244 php-src/NEWS:1.2027.2.547.2.1245
--- php-src/NEWS:1.2027.2.547.2.1244    Tue Oct  7 14:35:03 2008
+++ php-src/NEWS        Tue Oct  7 15:31:47 2008
@@ -18,6 +18,8 @@
   (Scott)
 - Fixed a crash on invalid method in ReflectionParameter constructor.
   (Christian Seiler)
+- Fixed bug #46247 (ibase_set_event_handler() is allowing to pass callback
+  without event). (Felipe)
 - Fixed bug #46215 (json_encode mutates its parameter and has some 
   class-specific state). (Felipe)
 - Fixed bug #46206 (pg_query_params/pg_execute convert passed values to
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_events.c?r1=1.8.2.1.2.2&r2=1.8.2.1.2.3&diff_format=u
Index: php-src/ext/interbase/ibase_events.c
diff -u php-src/ext/interbase/ibase_events.c:1.8.2.1.2.2 
php-src/ext/interbase/ibase_events.c:1.8.2.1.2.3
--- php-src/ext/interbase/ibase_events.c:1.8.2.1.2.2    Mon Dec 31 07:20:07 2007
+++ php-src/ext/interbase/ibase_events.c        Tue Oct  7 15:31:48 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_events.c,v 1.8.2.1.2.2 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_events.c,v 1.8.2.1.2.3 2008/10/07 15:31:48 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -268,8 +268,8 @@
        int link_res_id;
 
        RESET_ERRMSG;
-
-       /* no more than 15 events */
+       
+       /* Minimum and maximum number of arguments allowed */
        if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 17) {
                WRONG_PARAM_COUNT;
        }
@@ -280,6 +280,12 @@
 
        /* get a working link */
        if (Z_TYPE_PP(args[0]) != IS_STRING) {
+               /* resource, callback, event_1 [, ... event_15]
+                * No more than 15 events
+                */
+               if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 17) {
+                       WRONG_PARAM_COUNT;
+               }
 
                cb_arg = args[1];
                i = 2;
@@ -291,8 +297,10 @@
                link_res_id = Z_LVAL_PP(args[0]);
 
        } else {
-
-               if (ZEND_NUM_ARGS() > 16) {
+               /* callback, event_1 [, ... event_15] 
+                * No more than 15 events
+                */
+               if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 16) {
                        WRONG_PARAM_COUNT;
                }
 

http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/tests/bug46247.phpt?view=markup&rev=1.1
Index: php-src/ext/interbase/tests/bug46247.phpt
+++ php-src/ext/interbase/tests/bug46247.phpt
--TEST--
Bug #46247 (ibase_set_event_handler() is allowing to pass callback without 
event)
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php

require("interbase.inc");

$db = ibase_connect($test_base);

function test() { }

ibase_set_event_handler();

ibase_set_event_handler('test', 1);
ibase_set_event_handler($db, 'test', 1);
ibase_set_event_handler(NULL, 'test', 1);


ibase_set_event_handler('foo', 1);
ibase_set_event_handler($db, 'foo', 1);
ibase_set_event_handler(NULL, 'foo', 1);

?>
--EXPECTF--

Warning: Wrong parameter count for ibase_set_event_handler() in %s on line %d

Warning: ibase_set_event_handler(): supplied argument is not a valid InterBase 
link resource in %s on line %d

Warning: ibase_set_event_handler(): Callback argument foo is not a callable 
function in %s on line %d

Warning: ibase_set_event_handler(): Callback argument foo is not a callable 
function in %s on line %d

Warning: ibase_set_event_handler(): supplied argument is not a valid InterBase 
link resource in %s on line %d



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to