diff options
author | Jeremy Allison <jra@samba.org> | 2015-06-09 12:42:10 -0700 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2015-12-09 17:19:50 +0100 |
commit | ec504dbf69636a554add1f3d5703dd6c3ad450b8 (patch) | |
tree | 8e19f7ddc6119ac18d8a0cc7f62e14d34dfd4321 /lib | |
parent | 3c6ea3293c6aac67bc442f47185fd494714e4806 (diff) | |
download | samba-ec504dbf69636a554add1f3d5703dd6c3ad450b8.tar.gz |
CVE-2015-3223: lib: ldb: Cope with canonicalise_fn returning string "", length 0.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11325
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/common/ldb_match.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/ldb/common/ldb_match.c b/lib/ldb/common/ldb_match.c index a493daec49f..7414289b613 100644 --- a/lib/ldb/common/ldb_match.c +++ b/lib/ldb/common/ldb_match.c @@ -271,6 +271,14 @@ static int ldb_wildcard_compare(struct ldb_context *ldb, if (cnk.length > val.length) { goto mismatch; } + /* + * Empty strings are returned as length 0. Ensure + * we can cope with this. + */ + if (cnk.length == 0) { + goto mismatch; + } + if (memcmp((char *)val.data, (char *)cnk.data, cnk.length) != 0) goto mismatch; val.length -= cnk.length; val.data += cnk.length; @@ -284,7 +292,13 @@ static int ldb_wildcard_compare(struct ldb_context *ldb, chunk = tree->u.substring.chunks[c]; if(a->syntax->canonicalise_fn(ldb, ldb, chunk, &cnk) != 0) goto mismatch; - /* FIXME: case of embedded nulls */ + /* + * Empty strings are returned as length 0. Ensure + * we can cope with this. + */ + if (cnk.length == 0) { + goto mismatch; + } p = strstr((char *)val.data, (char *)cnk.data); if (p == NULL) goto mismatch; if ( (! tree->u.substring.chunks[c + 1]) && (! tree->u.substring.end_with_wildcard) ) { |