|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72975 ldap_escape could produce string larger than 2Gb
Submitted: 2016-08-30 14:03 UTC Modified: 2017-02-13 01:25 UTC
From: nguyenluan dot vnn at gmail dot com Assigned: stas (profile)
Status: Closed Package: LDAP related
PHP Version: 5.6.25 OS:
Private report: No CVE-ID: None
 [2016-08-30 14:03 UTC] nguyenluan dot vnn at gmail dot com
The ldap_escape function does NOT check for the MAX output string length. It can produce string larger than 2Gb. This string is considered invalid in PHP 5 and could lead to memory corruption when feed to other functions.

Test script:
	ini_set('memory_limit', -1);

	$str = str_repeat('a', 0x40000000).'\\\\\\\\'.str_repeat('+', 0x40000000 - 5);

	$str1 = ldap_escape($str, null, LDAP_ESCAPE_FILTER);

Expected result:
Error, output string length larger than 2Gb

Actual result:
int(-2147483641)  // output string with length > 2Gb


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-09-02 06:31 UTC]
-Assigned To: +Assigned To: stas
 [2016-09-02 06:31 UTC]
The fix is in security repo as 0f1eb74e92191e817b4198ceda4e8f093699da62 and in
please verify
 [2016-09-02 16:06 UTC] nguyenluan dot vnn at gmail dot com
The patch is good.
 [2016-09-13 04:12 UTC]
-Status: Assigned +Status: Closed
 [2016-09-13 04:12 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2016-09-13 12:36 UTC] nguyenluan dot vnn at gmail dot com
Can you assign a CVE number for this?
 [2016-09-13 16:59 UTC]
I don't think this needs a CVE. Running without memory limit in production and escaping user-suppied 2G string does not look like a common scenario. Same for all other non-memory-limit issues.
 [2016-09-14 14:01 UTC] nguyenluan dot vnn at gmail dot com
But in this bug, running without memory limit and opening large path name still have CVE number.
 [2017-02-13 01:25 UTC]
-Type: Security +Type: Bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 21 07:01:27 2024 UTC