From: Kurt Zeilenga Date: Sun, 27 Nov 2005 01:03:41 +0000 (+0000) Subject: Sync with HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_3_13~8 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a9c4a150872b7b31225cc727a38d7355d2cdff85;p=openldap Sync with HEAD --- diff --git a/libraries/libldap/add.c b/libraries/libldap/add.c index 35b0cb6ed1..88b849b359 100644 --- a/libraries/libldap/add.c +++ b/libraries/libldap/add.c @@ -136,19 +136,22 @@ ldap_add_ext( return ld->ld_errno; } - /* for each attribute in the entry... */ - for ( i = 0; attrs[i] != NULL; i++ ) { - if ( ( attrs[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { - rc = ber_printf( ber, "{s[V]N}", attrs[i]->mod_type, - attrs[i]->mod_bvalues ); - } else { - rc = ber_printf( ber, "{s[v]N}", attrs[i]->mod_type, - attrs[i]->mod_values ); - } - if ( rc == -1 ) { - ld->ld_errno = LDAP_ENCODING_ERROR; - ber_free( ber, 1 ); - return ld->ld_errno; + /* allow attrs to be NULL ("touch"; should fail...) */ + if ( attrs ) { + /* for each attribute in the entry... */ + for ( i = 0; attrs[i] != NULL; i++ ) { + if ( ( attrs[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { + rc = ber_printf( ber, "{s[V]N}", attrs[i]->mod_type, + attrs[i]->mod_bvalues ); + } else { + rc = ber_printf( ber, "{s[v]N}", attrs[i]->mod_type, + attrs[i]->mod_values ); + } + if ( rc == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return ld->ld_errno; + } } } diff --git a/libraries/libldap/modify.c b/libraries/libldap/modify.c index d7ca681bed..a03fd47057 100644 --- a/libraries/libldap/modify.c +++ b/libraries/libldap/modify.c @@ -103,22 +103,25 @@ ldap_modify_ext( LDAP *ld, return( ld->ld_errno ); } - /* for each modification to be performed... */ - for ( i = 0; mods[i] != NULL; i++ ) { - if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { - rc = ber_printf( ber, "{e{s[V]N}N}", - (ber_int_t) ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ), - mods[i]->mod_type, mods[i]->mod_bvalues ); - } else { - rc = ber_printf( ber, "{e{s[v]N}N}", - (ber_int_t) mods[i]->mod_op, - mods[i]->mod_type, mods[i]->mod_values ); - } - - if ( rc == -1 ) { - ld->ld_errno = LDAP_ENCODING_ERROR; - ber_free( ber, 1 ); - return( ld->ld_errno ); + /* allow mods to be NULL ("touch") */ + if ( mods ) { + /* for each modification to be performed... */ + for ( i = 0; mods[i] != NULL; i++ ) { + if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) { + rc = ber_printf( ber, "{e{s[V]N}N}", + (ber_int_t) ( mods[i]->mod_op & ~LDAP_MOD_BVALUES ), + mods[i]->mod_type, mods[i]->mod_bvalues ); + } else { + rc = ber_printf( ber, "{e{s[v]N}N}", + (ber_int_t) mods[i]->mod_op, + mods[i]->mod_type, mods[i]->mod_values ); + } + + if ( rc == -1 ) { + ld->ld_errno = LDAP_ENCODING_ERROR; + ber_free( ber, 1 ); + return( ld->ld_errno ); + } } }