mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
strengthen dn_issuffix
This commit is contained in:
parent
f461eb5c72
commit
7330016026
@ -450,16 +450,32 @@ char **dn_subtree(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
dn_issuffixbv(
|
dn_issuffixbv(
|
||||||
const struct berval *dn,
|
const struct berval *dn,
|
||||||
const struct berval *suffix
|
const struct berval *suffix
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (suffix->bv_len > dn->bv_len)
|
int d = dn->bv_len - suffix->bv_len;
|
||||||
return 0;
|
|
||||||
|
|
||||||
return( strcmp( dn->bv_val + dn->bv_len - suffix->bv_len,
|
/* suffix longer than dn */
|
||||||
suffix->bv_val ) == 0 );
|
if ( d < 0 ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no rdn separator or escaped rdn separator */
|
||||||
|
if ( d > 1 && ( !DN_SEPARATOR( dn->bv_val[ d - 1 ] )
|
||||||
|
|| DN_ESCAPE( dn->bv_val[ d - 2 ] ) ) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no possible match or malformed dn */
|
||||||
|
if ( d == 1 ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* compare */
|
||||||
|
return( strcmp( dn->bv_val + d, suffix->bv_val ) == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -473,20 +489,14 @@ dn_issuffix(
|
|||||||
const char *suffix
|
const char *suffix
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int dnlen, suffixlen;
|
struct berval bvdn, bvsuffix;
|
||||||
|
|
||||||
if ( dn == NULL ) {
|
bvdn.bv_val = (char *) dn;
|
||||||
return( 0 );
|
bvdn.bv_len = strlen( dn );
|
||||||
}
|
bvsuffix.bv_val = (char *) suffix;
|
||||||
|
bvsuffix.bv_len = strlen( suffix );
|
||||||
|
|
||||||
suffixlen = strlen( suffix );
|
return dn_issuffixbv( &bvdn, &bvsuffix );
|
||||||
dnlen = strlen( dn );
|
|
||||||
|
|
||||||
if ( suffixlen > dnlen ) {
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return( strcmp( dn + dnlen - suffixlen, suffix ) == 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user