ldb_compre_base - can you clarify this test?

Andrew Bartlett abartlet at samba.org
Wed Oct 29 12:14:40 GMT 2008


On Wed, 2008-10-29 at 07:57 -0400, simo wrote:
> On Wed, 2008-10-29 at 13:46 +1100, Andrew Bartlett wrote:
> > In this function, from ldb_dn.c, I'm concerned about the use of strlen():
> > 
> > int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
> > {
> > 	int ret;
> > 	int n_base, n_dn;
> > 
> > 	if ( ! base || base->invalid) return 1;
> > 	if ( ! dn || dn->invalid) return -1;
> > 
> > 	if (( ! base->valid_case) || ( ! dn->valid_case)) {
> > 		if (base->linearized && dn->linearized) {
> > 			/* try with a normal compare first, if we are lucky
> > 			 * we will avoid exploding and casfolding */
> > 			int dif;
> > 			dif = strlen(dn->linearized) - strlen(base->linearized);
> > 			if (dif < 0) return dif;
> > 			if (strcmp(base->linearized, &dn->linearized[dif]) == 0) return 0;
> > 		}
> > 
> > Firstly, it is my understanding that there are some (annoying)
> > characters are longer when upper cased.  Secondly, could dn->liniarized
> > contain escaped characters?
> > 
> > If either of these are true, is it valid to do the comparisons like this?
> 
> linearized strings are also canonicalized (As you see later on there is
> a straight strcmp), there is no problem in doing a length comparison.

How so?  ldb_dn_new() sets the linearized string directly.  I have not
yet found the function that does the canonicalization.  

Andrew Bartlett

-- 
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org
Samba Developer, Red Hat Inc.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20081029/77107718/attachment.bin


More information about the samba-technical mailing list