1--TEST--
2GHSA-g665-fm4p-vhff (OOB access in ldap_escape)
3--EXTENSIONS--
4ldap
5--INI--
6memory_limit=-1
7--SKIPIF--
8<?php
9if (PHP_INT_SIZE !== 4) die("skip only for 32-bit");
10if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
11?>
12--FILE--
13<?php
14try {
15    ldap_escape(' '.str_repeat("#", 1431655758), "", LDAP_ESCAPE_DN);
16} catch (ValueError $e) {
17    echo $e->getMessage(), "\n";
18}
19
20try {
21    ldap_escape(str_repeat("#", 1431655758).' ', "", LDAP_ESCAPE_DN);
22} catch (ValueError $e) {
23    echo $e->getMessage(), "\n";
24}
25?>
26--EXPECT--
27ldap_escape(): Argument #1 ($value) is too long
28ldap_escape(): Argument #1 ($value) is too long
29