]> git.sur5r.net Git - openldap/commitdiff
Sync with HEAD
authorKurt Zeilenga <kurt@openldap.org>
Sun, 27 Nov 2005 01:03:41 +0000 (01:03 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 27 Nov 2005 01:03:41 +0000 (01:03 +0000)
libraries/libldap/add.c
libraries/libldap/modify.c

index 35b0cb6ed1a77134af61b214ab1a127efb3fdb0a..88b849b3599adca773c2ab9f5787531050edd793 100644 (file)
@@ -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;
+                       }
                }
        }
 
index d7ca681bed89c94cb9d41afe5287ac11918144c8..a03fd47057663c5372d73599e2522fe206cea65f 100644 (file)
@@ -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 );
+                       }
                }
        }