]> git.sur5r.net Git - openldap/commitdiff
Use ber_dupbv() to avoid crashing on binary values
authorLuke Howard <lukeh@openldap.org>
Wed, 22 Jan 2003 14:53:03 +0000 (14:53 +0000)
committerLuke Howard <lukeh@openldap.org>
Wed, 22 Jan 2003 14:53:03 +0000 (14:53 +0000)
servers/slapd/slapi/slapi_utils.c

index f61d8b38a4b319ea6c667c4d23031005057c00a0..47095742a29f34190e33a033e840f9aa0a7e381d 100644 (file)
@@ -509,9 +509,7 @@ slapi_attr_get_values(
 
        bv = (struct berval **)ch_malloc( (i + 1) * sizeof(struct berval *) );
        for ( j = 0; j < i; j++ ) {
-               bv[j] = (struct berval *)ch_malloc( sizeof(struct berval) );
-               bv[j]->bv_val = ch_strdup( attr->a_vals[j].bv_val );
-               bv[j]->bv_len = attr->a_vals[j].bv_len;
+               bv[j] = ber_dupbv( NULL, &attr->a_vals[j] );
        }
        bv[j] = NULL;
        
@@ -1107,18 +1105,11 @@ slapi_filter_get_ava(
                        goto done;
                }
 
-               *bval = (struct berval *)slapi_ch_malloc( sizeof(struct berval) );
+               *bval = ber_dupbv( NULL, &f->f_un.f_un_ava->aa_value );
                if ( *bval == NULL ) {
                        rc = LDAP_NO_MEMORY;
                        goto done;
                }
-
-               (*bval)->bv_len = f->f_un.f_un_ava->aa_value.bv_len;
-               (*bval)->bv_val = slapi_ch_strdup( f->f_un.f_un_ava->aa_value.bv_val );
-               if ( (*bval)->bv_val == NULL ) {
-                       rc = LDAP_NO_MEMORY;
-                       goto done;
-               }
        } else { /* filter type not supported */
                rc = -1;
        }