Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class Bar extends Foo

?>
--EXPECTF--
Fatal error: Type of Bar::$property1 must not be defined (as in class Foo) in %s on line %d
Fatal error: Type of Bar::$property1 must be omitted to match the parent definition in class Foo in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/typed_properties_035.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class Baz extends Foo{
}
?>
--EXPECTF--
Fatal error: Type of Baz::$bar must not be defined (as in class Foo) in %s on line 6
Fatal error: Type of Baz::$bar must be omitted to match the parent definition in class Foo in %s on line 6
2 changes: 1 addition & 1 deletion Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
}
} else if (UNEXPECTED(ZEND_TYPE_IS_SET(child_info->type) && !ZEND_TYPE_IS_SET(parent_info->type))) {
zend_error_noreturn(E_COMPILE_ERROR,
"Type of %s::$%s must not be defined (as in class %s)",
"Type of %s::$%s must be omitted to match the parent definition in class %s",
ZSTR_VAL(ce->name),
ZSTR_VAL(key),
ZSTR_VAL(parent_info->ce->name));
Expand Down
20 changes: 18 additions & 2 deletions ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3759,13 +3759,23 @@ static zend_string* php_ldap_do_escape(const bool *map, const char *value, size_
zend_string *ret;

for (i = 0; i < valuelen; i++) {
len += (map[(unsigned char) value[i]]) ? 3 : 1;
size_t addend = (map[(unsigned char) value[i]]) ? 3 : 1;
if (len > ZSTR_MAX_LEN - addend) {
return NULL;
}
len += addend;
}
/* Per RFC 4514, a leading and trailing space must be escaped */
if ((flags & PHP_LDAP_ESCAPE_DN) && (value[0] == ' ')) {
if (len > ZSTR_MAX_LEN - 2) {
return NULL;
}
len += 2;
}
if ((flags & PHP_LDAP_ESCAPE_DN) && ((valuelen > 1) && (value[valuelen - 1] == ' '))) {
if (len > ZSTR_MAX_LEN - 2) {
return NULL;
}
len += 2;
}

Expand Down Expand Up @@ -3832,7 +3842,13 @@ PHP_FUNCTION(ldap_escape)
php_ldap_escape_map_set_chars(map, ignores, ignoreslen, 0);
}

RETURN_NEW_STR(php_ldap_do_escape(map, value, valuelen, flags));
zend_string *result = php_ldap_do_escape(map, value, valuelen, flags);
if (UNEXPECTED(!result)) {
zend_argument_value_error(1, "is too long");
RETURN_THROWS();
}

RETURN_NEW_STR(result);
}

#ifdef STR_TRANSLATION
Expand Down
28 changes: 28 additions & 0 deletions ext/ldap/tests/GHSA-g665-fm4p-vhff-1.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
GHSA-g665-fm4p-vhff (OOB access in ldap_escape)
--EXTENSIONS--
ldap
--INI--
memory_limit=-1
--SKIPIF--
<?php
if (PHP_INT_SIZE !== 4) die("skip only for 32-bit");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
try {
ldap_escape(' '.str_repeat("#", 1431655758), "", LDAP_ESCAPE_DN);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}

try {
ldap_escape(str_repeat("#", 1431655758).' ', "", LDAP_ESCAPE_DN);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
ldap_escape(): Argument #1 ($value) is too long
ldap_escape(): Argument #1 ($value) is too long
29 changes: 29 additions & 0 deletions ext/ldap/tests/GHSA-g665-fm4p-vhff-2.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
GHSA-g665-fm4p-vhff (OOB access in ldap_escape)
--EXTENSIONS--
ldap
--INI--
memory_limit=-1
--SKIPIF--
<?php
if (PHP_INT_SIZE !== 4) die("skip only for 32-bit");
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
try {
ldap_escape(str_repeat("*", 1431655759), "", LDAP_ESCAPE_FILTER);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}

// would allocate a string of length 2
try {
ldap_escape(str_repeat("*", 1431655766), "", LDAP_ESCAPE_FILTER);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
ldap_escape(): Argument #1 ($value) is too long
ldap_escape(): Argument #1 ($value) is too long
Loading