summaryrefslogtreecommitdiff
path: root/source3/lib/ldb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-10-09 07:15:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:20 -0500
commitd63a3e05a23ffb016578c3daa8b48d6fc32e1e8c (patch)
tree60ff3225bd32711951cbb5e80727060f0bc8f87c /source3/lib/ldb
parent617c39ab5ffbefcd7d0536c72ffbb0c36ce04215 (diff)
downloadsamba-d63a3e05a23ffb016578c3daa8b48d6fc32e1e8c.tar.gz
samba-d63a3e05a23ffb016578c3daa8b48d6fc32e1e8c.tar.bz2
samba-d63a3e05a23ffb016578c3daa8b48d6fc32e1e8c.zip
r19183: merge from samba4:
don't crash on invalid utf8 chars metze (This used to be commit 71e1f8550f96eaaae7e4fc4d02eb36f1d894abc8)
Diffstat (limited to 'source3/lib/ldb')
-rw-r--r--source3/lib/ldb/common/attrib_handlers.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source3/lib/ldb/common/attrib_handlers.c b/source3/lib/ldb/common/attrib_handlers.c
index c4c83c52a6..07a0ec6eb8 100644
--- a/source3/lib/ldb/common/attrib_handlers.c
+++ b/source3/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;
}