diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-09-28 17:06:38 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:20:26 -0500 |
commit | c2a2c2456d807784bdacb9e088044a85fe278315 (patch) | |
tree | 7805557588fb5f11da98cae55235a60b1d235f6c /source4/lib/ldb | |
parent | eaa427801a3aadd92a467ca6df4d41e37fb74810 (diff) | |
download | samba-c2a2c2456d807784bdacb9e088044a85fe278315.tar.gz samba-c2a2c2456d807784bdacb9e088044a85fe278315.tar.bz2 samba-c2a2c2456d807784bdacb9e088044a85fe278315.zip |
r18978: Fix bug found by:
http://www.ee.oulu.fi/research/ouspg/protos/testing/c06/ldapv3/
The issue here is that if the UTF8 conversion fails, because this
isn't actually UTF8 data, then we need to do a binary compare instead.
Andrew Bartlett
(This used to be commit a113e47784157ec6086b014c1fc998e8a23e7382)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/common/attrib_handlers.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c index 8e437964f4..df70ca1b51 100644 --- a/source4/lib/ldb/common/attrib_handlers.c +++ b/source4/lib/ldb/common/attrib_handlers.c @@ -184,10 +184,19 @@ static int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx, return (int)(toupper(*s1)) - (int)(toupper(*s2)); utf8str: - /* non need to recheck from the start, just from the first utf8 char found */ + /* no need to recheck from the start, just from the first utf8 char found */ b1 = u1 = ldb_casefold(ldb, mem_ctx, s1); b2 = u2 = ldb_casefold(ldb, mem_ctx, s2); - + + if (u1 && u2) { + /* Both strings converted correctly */ + } else { + /* One of the strings was not UTF8, so we have no options but to do a binary compare */ + + u1 = s1; + u2 = s2; + } + while (*u1 & *u2) { if (*u1 != *u2) break; @@ -202,9 +211,10 @@ utf8str: while (*u2 == ' ') u2++; } ret = (int)(*u1 - *u2); + talloc_free(b1); talloc_free(b2); - + return ret; } |