From 528470d4a74b1e2068fdc98b62076e8b19db47fc Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 21:39:37 +0000 Subject: r12748: Fix wrong handling of separation characters for RDNs allow escaped separation chars as part of the attr value of an RDN (This used to be commit 7ba341d6c3745cd99c4c79933f9bd54f41e12a9c) --- source4/lib/ldb/common/ldb_dn.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/common') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index 5ed54ae316..4164814f4f 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -214,8 +214,8 @@ failed: static char *seek_to_separator(char *string, const char *separators) { - char *p; - int ret, qs, qe; + char *p, *q; + int ret, qs, qe, escaped; if (string == NULL || separators == NULL) return NULL; @@ -242,11 +242,21 @@ static char *seek_to_separator(char *string, const char *separators) } /* no quotes found seek to separators */ - ret = strcspn(p, separators); - if (ret == 0) /* no separators ?! bail out */ + q = p; + do { + escaped = 0; + ret = strcspn(q, separators); + + if (q[ret - 1] == '\\') { + escaped = 1; + q = q + ret + 1; + } + } while (escaped); + + if (ret == 0 && p == q) /* no separators ?! bail out */ return NULL; - return p + ret; + return q + ret; failed: return NULL; -- cgit