svn commit: samba r19183 - in branches/SAMBA_3_0/source/lib/ldb/common: .

metze at samba.org metze at samba.org
Mon Oct 9 07:15:28 GMT 2006


Author: metze
Date: 2006-10-09 07:15:27 +0000 (Mon, 09 Oct 2006)
New Revision: 19183

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19183

Log:
merge from samba4:

don't crash on invalid utf8 chars

metze
Modified:
   branches/SAMBA_3_0/source/lib/ldb/common/attrib_handlers.c


Changeset:
Modified: branches/SAMBA_3_0/source/lib/ldb/common/attrib_handlers.c
===================================================================
--- branches/SAMBA_3_0/source/lib/ldb/common/attrib_handlers.c	2006-10-09 07:05:08 UTC (rev 19182)
+++ branches/SAMBA_3_0/source/lib/ldb/common/attrib_handlers.c	2006-10-09 07:15:27 UTC (rev 19183)
@@ -184,10 +184,19 @@
 	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 @@
 		while (*u2 == ' ') u2++;
 	}
 	ret = (int)(*u1 - *u2);
+
 	talloc_free(b1);
 	talloc_free(b2);
-
+	
 	return ret;
 }
 



More information about the samba-cvs mailing list