CVE-2015-5330: ldb_dn: simplify and fix ldb_dn_escape_internal()
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 24 Nov 2015 00:07:23 +0000 (13:07 +1300)
committerRalph Boehme <slow@samba.org>
Wed, 9 Dec 2015 16:18:03 +0000 (17:18 +0100)
commit813eceafcada3a2ce260499d8792a943426bdac9
tree661966b22194d2c8ed96ea664ffd352c5e574048
parent3c68b500a7beca60559dc073f53cc1aa1f9a8ba1
CVE-2015-5330: ldb_dn: simplify and fix ldb_dn_escape_internal()

Previously we relied on NUL terminated strings and jumped back and
forth between copying escaped bytes and memcpy()ing un-escaped chunks.
This simple version is easier to reason about and works with
unterminated strings. It may also be faster as it avoids reading the
string twice (first with strcspn, then with memcpy).

Bug: https://bugzilla.samba.org/show_bug.cgi?id=11599

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Pair-programmed-with: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
lib/ldb/common/ldb_dn.c