ldb_compre_base - can you clarify this test?
simo
idra at samba.org
Wed Oct 29 11:57:51 GMT 2008
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.
Simo.
--
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Senior Software Engineer at Red Hat Inc. <simo at redhat.com>
More information about the samba-technical
mailing list