Skip to content

Commit

Permalink
Do not allow using traits/interfaces/abstract classes as stream wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
sgolemon committed Jul 19, 2017
1 parent 2cca43b commit c9fd093
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ext/standard/tests/streams/bug74951.phpt
@@ -0,0 +1,12 @@
--TEST--
Bug#74951 Null pointer dereference in user streams
--FILE--
<?php
trait Stream00ploiter{
public function s() {}
public function n($_) {}
}
stream_wrapper_register('e0ploit','Stream00ploiter');
$s=fopen('e0ploit://',0);
--EXPECTF--
Warning: fopen(e0ploit://): failed to open stream: operation failed in %s/bug74951.php on line 7
5 changes: 5 additions & 0 deletions main/streams/userspace.c
Expand Up @@ -283,6 +283,11 @@ typedef struct _php_userstream_data php_userstream_data_t;

static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php_stream_context *context, zval *object)
{
if (uwrap->ce->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
ZVAL_UNDEF(object);
return;
}

/* create an instance of our class */
object_init_ex(object, uwrap->ce);

Expand Down

0 comments on commit c9fd093

Please sign in to comment.