X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fadd.c;h=47fa3c7eb4617ef33e8802e897a717b15cc6697f;hb=b898f1271db5021e1873e38e1498a99d9450b646;hp=f36dfc8a0f05269be3fae9acdf0ebdbd62437959;hpb=b984564dbdb38eaac38273cb636108d228398cb3;p=openldap diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index f36dfc8a0f..47fa3c7eb4 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2007 The OpenLDAP Foundation. + * Copyright 1998-2010 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -151,9 +151,32 @@ ldap_add_ext( /* for each attribute in the entry... */ for ( i = 0; attrs[i] != NULL; i++ ) { if ( ( attrs[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { + int j; + + if ( attrs[i]->mod_bvalues == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + ber_free( ber, 1 ); + return ld->ld_errno; + } + + for ( j = 0; attrs[i]->mod_bvalues[ j ] != NULL; j++ ) { + if ( attrs[i]->mod_bvalues[ j ]->bv_val == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + ber_free( ber, 1 ); + return ld->ld_errno; + } + } + rc = ber_printf( ber, "{s[V]N}", attrs[i]->mod_type, attrs[i]->mod_bvalues ); + } else { + if ( attrs[i]->mod_values == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + ber_free( ber, 1 ); + return ld->ld_errno; + } + rc = ber_printf( ber, "{s[v]N}", attrs[i]->mod_type, attrs[i]->mod_values ); }