]> git.sur5r.net Git - openldap/commitdiff
back-mdb Multival fixes
authorHoward Chu <hyc@openldap.org>
Thu, 22 Feb 2018 03:12:32 +0000 (03:12 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 28 Feb 2018 22:37:38 +0000 (22:37 +0000)
Fix multival logic on Replace
Fix return codes from modify_internal, id2entry_put

servers/slapd/back-mdb/id2entry.c
servers/slapd/back-mdb/modify.c

index 6244dd77ca247886000fd75b3950b468d6867327..4356363ea7184639bcb59bef27a0ce07ba6422d0 100644 (file)
@@ -307,18 +307,23 @@ again:
                        MDB_cursor *mvc;
                        Attribute *a;
                        rc = mdb_cursor_open( txn, mdb->mi_dbis[MDB_ID2VAL], &mvc );
-                       if( rc )
-                               return rc;
-                       for ( a = ec.multi; a; a=a->a_next ) {
-                               if (!(a->a_flags & SLAP_ATTR_BIG_MULTI))
-                                       continue;
-                               rc = mdb_mval_put( op, mvc, e->e_id, a );
-                               if( rc != LDAP_SUCCESS )
-                                       break;
+                       if( !rc ) {
+                               for ( a = ec.multi; a; a=a->a_next ) {
+                                       if (!(a->a_flags & SLAP_ATTR_BIG_MULTI))
+                                               continue;
+                                       rc = mdb_mval_put( op, mvc, e->e_id, a );
+                                       if( rc )
+                                               break;
+                               }
+                               mdb_cursor_close( mvc );
+                       }
+                       if ( rc ) {
+                               Debug( LDAP_DEBUG_ANY,
+                                       "mdb_id2entry_put: mdb_mval_put failed: %s(%d) \"%s\"\n",
+                                       mdb_strerror(rc), rc,
+                                       e->e_nname.bv_val );
+                               return LDAP_OTHER;
                        }
-                       mdb_cursor_close( mvc );
-                       if ( rc )
-                               return rc;
                }
        }
        if (rc) {
index 7bfdb5cd58a557b2d9fdcdcb205ea5a5880727eb..e0ca295904de856d85c1de72bd7a7f5021fd7c13 100644 (file)
@@ -183,8 +183,11 @@ do_add:
                                if ( anew->a_flags & SLAP_ATTR_BIG_MULTI ) {
                                        if (!mvc) {
                                                err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
-                                               if (err)
+                                               if (err) {
+mval_fail:                                     strncpy( textbuf, mdb_strerror( err ), textlen );
+                                                       err = LDAP_OTHER;
                                                        break;
+                                               }
                                        }
                                        /* if prev was set, just add new values */
                                        if (a_flags & SLAP_ATTR_BIG_MULTI ) {
@@ -199,6 +202,8 @@ do_add:
                                                if (anew->a_nvals == anew->a_vals)
                                                        anew->a_nvals = NULL;
                                        }
+                                       if ( err )
+                                               goto mval_fail;
                                }
                        }
                        break;
@@ -237,7 +242,7 @@ do_del:
                                        if (!mvc) {
                                                err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
                                                if (err)
-                                                       break;
+                                                       goto mval_fail;
                                        }
                                        if ( mod->sm_numvals ) {
                                                anew = attr_find( e->e_attrs, mod->sm_desc );
@@ -259,6 +264,8 @@ do_del:
                                                anew->a_numvals = 0;
                                        }
                                        err = mdb_mval_del( op, mvc, e->e_id, anew );
+                                       if ( err )
+                                               goto mval_fail;
                                }
                        }
                        break;
@@ -279,7 +286,7 @@ do_del:
                                        if (!mvc) {
                                                err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
                                                if (err)
-                                                       break;
+                                                       goto mval_fail;
                                        }
                                        /* delete all values */
                                        anew = &a_dummy;
@@ -287,17 +294,19 @@ do_del:
                                        anew->a_numvals = 0;
                                        err = mdb_mval_del( op, mvc, e->e_id, anew );
                                        if (err)
-                                               break;
+                                               goto mval_fail;
                                }
                                anew = attr_find( e->e_attrs, mod->sm_desc );
-                               if (mod->sm_numvals >= mdb->mi_multi_lo) {
+                               if (mod->sm_numvals > mdb->mi_multi_hi) {
                                        anew->a_flags |= SLAP_ATTR_BIG_MULTI;
                                        if (!mvc) {
                                                err = mdb_cursor_open( tid, mdb->mi_dbis[MDB_ID2VAL], &mvc );
                                                if (err)
-                                                       break;
+                                                       goto mval_fail;
                                        }
                                        err = mdb_mval_put(op, mvc, e->e_id, anew);
+                                       if (err)
+                                               goto mval_fail;
                                } else if (anew) {
                                        /* revert back to normal attr */
                                        anew->a_flags &= ~SLAP_ATTR_BIG_MULTI;