Skip to content

Reflection exception messages truncate on null bytes #22905

Description

@DanielEScherzer

After #22681 I looked into exception messages:

Reflection*::getAttributes() with ReflectionAttribute::IS_INSTANCEOF
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->getAttributes("foo\0bar", ReflectionAttribute::IS_INSTANCEOF);
ReflectionFunction::__construct()
<?php

new ReflectionFunction("foo\0bar");
ReflectionParameter::__construct() with string function
<?php

new ReflectionParameter("foo\0bar", 0);
ReflectionParameter::__construct() with array with class name
<?php

new ReflectionParameter(["foo\0bar", ""], 0);
ReflectionParameter::__construct() with array with method name
<?php

class Demo {}
new ReflectionParameter([Demo::class, "foo\0bar"], 0);
ReflectionMethod::__construct() with class name
<?php

new ReflectionMethod("foo\0bar", "");
ReflectionMethod::__construct() with method name
<?php

class Demo {}
new ReflectionMethod(Demo::class, "foo\0bar");

the above should also apply to ReflectionMethod::createFromMethodName() - they share the same lookup code

ReflectionClassConstant::__construct() with class name
<?php

new ReflectionClassConstant("foo\0bar", "");
ReflectionClassConstant::__construct() with constant name
<?php

class Demo {}
new ReflectionClassConstant(Demo::class, "foo\0bar");
ReflectionClass::__construct()
<?php

new ReflectionClass("foo\0bar");
ReflectionClass::getStaticPropertyValue()
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->getStaticPropertyValue("foo\0bar");
ReflectionClass::setStaticPropertyValue()
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->setStaticPropertyValue("foo\0bar", 123);
ReflectionClass::getMethod()
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->getMethod("foo\0bar");
ReflectionClass::getProperty()
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->getProperty("foo\0bar");
ReflectionClass::getProperty() (fully qualified)
<?php

class Base {}
class Demo {}
$r = new ReflectionClass(Demo::class);
$r->getProperty("Base::foo\0bar");
ReflectionClass::isSubclassOf()
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->isSubclassOf("foo\0bar");
ReflectionClass::implementsInterface()
<?php

class Demo {}
$r = new ReflectionClass(Demo::class);
$r->implementsInterface("foo\0bar");
ReflectionProperty::__construct() with class name
<?php

new ReflectionProperty("foo\0bar", "");
ReflectionProperty::__construct() with property name
<?php

class Demo {}
new ReflectionProperty(Demo::class, "foo\0bar");
ReflectionProperty::skipLazyInitialization() with property name
<?php

$o = (object)["foo\0bar" => "baz"];
$r = new ReflectionProperty($o, "foo\0bar");
$r->skipLazyInitialization($o);

also affects anything else using reflection_property_check_lazy_compatible()

ReflectionEnum::getCase() with missing case
<?php

enum Demo {}
$r = new ReflectionEnum(Demo::class);
$r->getCase("foo\0bar");
ReflectionConstant::__construct()
<?php

new ReflectionConstant("foo\0bar");

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions