X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fadd.c;h=6c8da84602fb77fff67eb452b6be63bb41c14068;hb=b905811d3c800b6f4031d541e424e5de871aa0c7;hp=d993650613fa70edf2581a63f476f2a625ee5e06;hpb=c890c96d13c53cf0fa1d9580fea2ab47a2c8caa9;p=openldap diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index d993650613..6c8da84602 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-2008 The OpenLDAP Foundation. + * Copyright 1998-2011 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 ); }