From d5c6fcc3ba275c79da85537f9792e4eb3c6a0c39 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 22 Apr 2017 16:44:20 +0200 Subject: Don't leak internal flags in reflection If someone complains, we may re-expose specific flags while also adding corresponding class constants for them. --- ext/reflection/php_reflection.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ext/reflection/php_reflection.c') diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index b9ae4d1c85..b8c984a8bf 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -3460,13 +3460,15 @@ ZEND_METHOD(reflection_method, getModifiers) { reflection_object *intern; zend_function *mptr; + uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC + | ZEND_ACC_STATIC | ZEND_ACC_ABSTRACT | ZEND_ACC_FINAL; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(mptr); - RETURN_LONG(mptr->common.fn_flags); + RETURN_LONG((mptr->common.fn_flags & keep_flags)); } /* }}} */ @@ -4663,13 +4665,15 @@ ZEND_METHOD(reflection_class, getModifiers) { reflection_object *intern; zend_class_entry *ce; + uint32_t keep_flags = ZEND_ACC_FINAL + | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS | ZEND_ACC_IMPLICIT_ABSTRACT_CLASS; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ce); - RETURN_LONG(ce->ce_flags & ~(ZEND_ACC_CONSTANTS_UPDATED|ZEND_ACC_USE_GUARDS|ZEND_ACC_INHERITED)); + RETURN_LONG((ce->ce_flags & keep_flags)); } /* }}} */ @@ -5451,13 +5455,14 @@ ZEND_METHOD(reflection_property, getModifiers) { reflection_object *intern; property_reference *ref; + uint32_t keep_flags = ZEND_ACC_PPP_MASK | ZEND_ACC_IMPLICIT_PUBLIC | ZEND_ACC_STATIC; if (zend_parse_parameters_none() == FAILURE) { return; } GET_REFLECTION_OBJECT_PTR(ref); - RETURN_LONG(ref->prop.flags); + RETURN_LONG((ref->prop.flags & keep_flags)); } /* }}} */ -- cgit v1.2.1