mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
honor the ber_len field to allow to exploit ldap_bv2[r]dn to handle DNs embedded in longer strings ...
This commit is contained in:
parent
a117c5eee7
commit
33d5f0f8f8
@ -621,6 +621,7 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
|
|||||||
LDAPRDN *newRDN = NULL, *tmpDN_[TMP_RDN_SLOTS], **tmpDN = tmpDN_;
|
LDAPRDN *newRDN = NULL, *tmpDN_[TMP_RDN_SLOTS], **tmpDN = tmpDN_;
|
||||||
int num_slots = TMP_RDN_SLOTS;
|
int num_slots = TMP_RDN_SLOTS;
|
||||||
char *str = bv->bv_val;
|
char *str = bv->bv_val;
|
||||||
|
char *end = str + bv->bv_len;
|
||||||
|
|
||||||
assert( bv );
|
assert( bv );
|
||||||
assert( bv->bv_val );
|
assert( bv->bv_val );
|
||||||
@ -679,7 +680,7 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; p[ 0 ]; p++ ) {
|
for ( ; p < end; p++ ) {
|
||||||
int err;
|
int err;
|
||||||
struct berval tmpbv = { bv->bv_len - ( p - str ), (char *)p };
|
struct berval tmpbv = { bv->bv_len - ( p - str ), (char *)p };
|
||||||
|
|
||||||
@ -691,7 +692,7 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
|
|||||||
/*
|
/*
|
||||||
* We expect a rdn separator
|
* We expect a rdn separator
|
||||||
*/
|
*/
|
||||||
if ( p[ 0 ] ) {
|
if ( p < end && p[ 0 ] ) {
|
||||||
switch ( LDAP_DN_FORMAT( flags ) ) {
|
switch ( LDAP_DN_FORMAT( flags ) ) {
|
||||||
case LDAP_DN_FORMAT_LDAPV3:
|
case LDAP_DN_FORMAT_LDAPV3:
|
||||||
if ( !LDAP_DN_RDN_SEP( p[ 0 ] ) ) {
|
if ( !LDAP_DN_RDN_SEP( p[ 0 ] ) ) {
|
||||||
@ -747,7 +748,7 @@ ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
|
|||||||
num_slots *= 2;
|
num_slots *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( p[ 0 ] == '\0' ) {
|
if ( p >= end || p[ 0 ] == '\0' ) {
|
||||||
/*
|
/*
|
||||||
* the DN is over, phew
|
* the DN is over, phew
|
||||||
*/
|
*/
|
||||||
|
@ -1348,22 +1348,18 @@ aci_match_set (
|
|||||||
/* format of string is "entry/setAttrName" */
|
/* format of string is "entry/setAttrName" */
|
||||||
if (aci_get_part(subj, 0, '/', &subjdn) < 0) {
|
if (aci_get_part(subj, 0, '/', &subjdn) < 0) {
|
||||||
return(0);
|
return(0);
|
||||||
} else {
|
|
||||||
/* FIXME: If dnNormalize was based on ldap_bv2dn
|
|
||||||
* instead of ldap_str2dn and would honor the bv_len
|
|
||||||
* we could skip this step and not worry about the
|
|
||||||
* unterminated string.
|
|
||||||
*/
|
|
||||||
char *s = ch_malloc(subjdn.bv_len + 1);
|
|
||||||
AC_MEMCPY(s, subjdn.bv_val, subjdn.bv_len);
|
|
||||||
subjdn.bv_val = s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( aci_get_part(subj, 1, '/', &setat) < 0 ) {
|
if ( aci_get_part(subj, 1, '/', &setat) < 0 ) {
|
||||||
setat.bv_val = SLAPD_ACI_SET_ATTR;
|
setat.bv_val = SLAPD_ACI_SET_ATTR;
|
||||||
setat.bv_len = sizeof(SLAPD_ACI_SET_ATTR)-1;
|
setat.bv_len = sizeof(SLAPD_ACI_SET_ATTR)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( setat.bv_val != NULL ) {
|
if ( setat.bv_val != NULL ) {
|
||||||
|
/*
|
||||||
|
* NOTE: dnNormalize2 honors the ber_len field
|
||||||
|
* as the length of the dn to be normalized
|
||||||
|
*/
|
||||||
if ( dnNormalize2(NULL, &subjdn, &ndn) == LDAP_SUCCESS
|
if ( dnNormalize2(NULL, &subjdn, &ndn) == LDAP_SUCCESS
|
||||||
&& slap_bv2ad(&setat, &desc, &text) == LDAP_SUCCESS )
|
&& slap_bv2ad(&setat, &desc, &text) == LDAP_SUCCESS )
|
||||||
{
|
{
|
||||||
@ -1384,7 +1380,6 @@ aci_match_set (
|
|||||||
if (ndn.bv_val)
|
if (ndn.bv_val)
|
||||||
free(ndn.bv_val);
|
free(ndn.bv_val);
|
||||||
}
|
}
|
||||||
ch_free(subjdn.bv_val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set.bv_val != NULL) {
|
if (set.bv_val != NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user