mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00
- MFH: Fixed bug #45575 (Segfault with invalid non-string as event handler callback)
patch by Christian seiler
This commit is contained in:
parent
d0ad1517f5
commit
e8f25c5b98
2 changed files with 27 additions and 4 deletions
|
@ -260,7 +260,7 @@ PHP_FUNCTION(ibase_set_event_handler)
|
|||
* link resource id (int) as arguments. The value returned from the function is
|
||||
* used to determine if the event handler should remain set.
|
||||
*/
|
||||
|
||||
char *cb_name;
|
||||
zval **args[17], **cb_arg;
|
||||
ibase_db_link *ib_link;
|
||||
ibase_event *event;
|
||||
|
@ -312,11 +312,12 @@ PHP_FUNCTION(ibase_set_event_handler)
|
|||
}
|
||||
|
||||
/* 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 %s is not a callable function" TSRMLS_CC, cb_name);
|
||||
efree(cb_name);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
efree(cb_name);
|
||||
|
||||
/* allocate the event resource */
|
||||
event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0);
|
||||
|
|
22
ext/interbase/tests/bug45575.phpt
Normal file
22
ext/interbase/tests/bug45575.phpt
Normal file
|
@ -0,0 +1,22 @@
|
|||
--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
|
Loading…
Add table
Add a link
Reference in a new issue