felipe Tue Oct 7 18:17:44 2008 UTC Added files: /php-src/ext/interbase/tests bug45575.phpt
Modified files: /php-src/ext/interbase ibase_events.c Log: - Fixed bug #45575 (Segfault with invalid non-string as event handler callback) patch by Christian seiler http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_events.c?r1=1.13&r2=1.14&diff_format=u Index: php-src/ext/interbase/ibase_events.c diff -u php-src/ext/interbase/ibase_events.c:1.13 php-src/ext/interbase/ibase_events.c:1.14 --- php-src/ext/interbase/ibase_events.c:1.13 Tue Oct 7 15:27:05 2008 +++ php-src/ext/interbase/ibase_events.c Tue Oct 7 18:17:44 2008 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ibase_events.c,v 1.13 2008/10/07 15:27:05 felipe Exp $ */ +/* $Id: ibase_events.c,v 1.14 2008/10/07 18:17:44 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -260,7 +260,7 @@ * link resource id (int) as arguments. The value returned from the function is * used to determine if the event handler should remain set. */ - + zval cb_name; zval **args[17], **cb_arg; ibase_db_link *ib_link; ibase_event *event; @@ -279,7 +279,7 @@ } /* get a working link */ - if (Z_TYPE_PP(args[0]) != IS_STRING) { + if (Z_TYPE_PP(args[0]) != IS_STRING && Z_TYPE_PP(args[0]) != IS_UNICODE) { /* resource, callback, event_1 [, ... event_15] * No more than 15 events */ @@ -312,11 +312,12 @@ } /* get the callback */ - if (!zend_is_callable(*cb_arg, 0, NULL TSRMLS_CC)) { - _php_ibase_module_error("Callback argument %s is not a callable function" - TSRMLS_CC, Z_STRVAL_PP(cb_arg)); + if (!zend_is_callable(*cb_arg, 0, &cb_name TSRMLS_CC)) { + _php_ibase_module_error("Callback argument %v is not a callable function" TSRMLS_CC, Z_UNIVAL(cb_name)); + zval_dtor(&cb_name); RETURN_FALSE; } + zval_dtor(&cb_name); /* allocate the event resource */ event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0); http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/tests/bug45575.phpt?view=markup&rev=1.1 Index: php-src/ext/interbase/tests/bug45575.phpt +++ php-src/ext/interbase/tests/bug45575.phpt --TEST-- Bug #45575 (Segfault with invalid non-string as event handler callback) --SKIPIF-- <?php include("skipif.inc"); ?> --FILE-- <?php require("interbase.inc"); $db = ibase_connect($test_base); function foobar($var) { var_dump($var); return true; } ibase_set_event_handler($db, null, 'TEST1'); ibase_set_event_handler($db, 1, 'TEST1'); ibase_set_event_handler('foobar', 'TEST1'); ?> --EXPECTF-- Warning: ibase_set_event_handler(): Callback argument is not a callable function in %s on line %d Warning: ibase_set_event_handler(): Callback argument 1 is not a callable function in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php