Skip to content

Commit

Permalink
Fixed bug #77494 (Disabling class causes segfault on member access)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jan 24, 2019
1 parent 526344a commit 73f222d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ PHP NEWS

- Core:
. Fixed bug #77339 (__callStatic may get incorrect arguments). (Dmitry)
. Fixed bug #77494 (Disabling class causes segfault on member access).
(Dmitry)

- Curl:
. Fixed bug #76675 (Segfault with H2 server push). (Pedro Magalhães)
Expand Down
16 changes: 16 additions & 0 deletions Zend/tests/bug77494.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Bug #77494 (Disabling class causes segfault on member access)
--SKIPIF--
<?php if (!extension_loaded("curl")) exit("skip curl extension not loaded"); ?>
--INI--
disable_classes=CURLFile
--FILE--
<?php
$a = new CURLFile();
var_dump($a->name);
?>
--EXPECTF--
Warning: CURLFile() has been disabled for security reasons in %sbug77494.php on line 2

Notice: Undefined property: CURLFile::$name in %sbug77494.php on line 3
NULL
11 changes: 11 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -2855,6 +2855,17 @@ static zend_object *display_disabled_class(zend_class_entry *class_type) /* {{{
zend_object *intern;

intern = zend_objects_new(class_type);

/* Initialize default properties */
if (EXPECTED(class_type->default_properties_count != 0)) {
zval *p = intern->properties_table;
zval *end = p + class_type->default_properties_count;
do {
ZVAL_UNDEF(p);
p++;
} while (p != end);
}

zend_error(E_WARNING, "%s() has been disabled for security reasons", ZSTR_VAL(class_type->name));
return intern;
}
Expand Down

0 comments on commit 73f222d

Please sign in to comment.