X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapi%2Fslapi_utils.c;h=3e1d1149baa062a0c06d710ddfe0e1f8ec7dbacd;hb=3647cba1315060683be59035759d5ccc1f2f6d2d;hp=ca370dd483d15fc19d045eff3816a268b9c1cfd5;hpb=2e36d49a7312e73de1a68c19facabb480590da88;p=openldap diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index ca370dd483..3e1d1149ba 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -226,12 +226,12 @@ slapi_entry_attr_merge( BerVarray bv; int rc; - rc = bvptr2obj( vals, &bv ); + rc = slap_str2ad( type, &ad, &text ); if ( rc != LDAP_SUCCESS ) { return -1; } - rc = slap_str2ad( type, &ad, &text ); + rc = bvptr2obj( vals, &bv ); if ( rc != LDAP_SUCCESS ) { return -1; } @@ -903,6 +903,7 @@ slapi_dn_parent( const char *_dn ) { struct berval dn, prettyDN; struct berval parentDN; + char *ret; if ( _dn == NULL ) { return NULL; @@ -921,13 +922,15 @@ slapi_dn_parent( const char *_dn ) dnParent( &prettyDN, &parentDN ); /* in-place */ - slapi_ch_free( (void **)&prettyDN.bv_val ); - if ( parentDN.bv_len == 0 ) { + slapi_ch_free_string( &prettyDN.bv_val ); return NULL; } - return slapi_ch_strdup( parentDN.bv_val ); + ret = slapi_ch_strdup( parentDN.bv_val ); + slapi_ch_free_string( &prettyDN.bv_val ); + + return ret; } int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *ldn ) @@ -2691,20 +2694,14 @@ int slapi_acl_check_mods(Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char /* * Synthesise an LDAPMod array from a Modifications list to pass - * to SLAPI. This synthesis is destructive and as such the - * Modifications list may not be used after calling this - * function. - * - * This function must also be called before slap_mods_check(). + * to SLAPI. */ -LDAPMod **slapi_int_modifications2ldapmods( Modifications **pmodlist ) +LDAPMod **slapi_int_modifications2ldapmods( Modifications *modlist ) { - Modifications *ml, *modlist; + Modifications *ml; LDAPMod **mods, *modp; int i, j; - modlist = *pmodlist; - for( i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next ) ; @@ -2731,14 +2728,9 @@ LDAPMod **slapi_int_modifications2ldapmods( Modifications **pmodlist ) for( j = 0; ml->sml_values[j].bv_val != NULL; j++ ) { modp->mod_bvalues[j] = (struct berval *)slapi_ch_malloc( sizeof(struct berval) ); - /* Take ownership of original values. */ - modp->mod_bvalues[j]->bv_len = ml->sml_values[j].bv_len; - modp->mod_bvalues[j]->bv_val = ml->sml_values[j].bv_val; - ml->sml_values[j].bv_len = 0; - ml->sml_values[j].bv_val = NULL; + ber_dupbv( modp->mod_bvalues[j], &ml->sml_values[j] ); } modp->mod_bvalues[j] = NULL; - slapi_ch_free( (void **)&ml->sml_values ); } else { modp->mod_bvalues = NULL; } @@ -2747,9 +2739,6 @@ LDAPMod **slapi_int_modifications2ldapmods( Modifications **pmodlist ) mods[i] = NULL; - slap_mods_free( modlist, 1 ); - *pmodlist = NULL; - return mods; }