]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/constraint.c
fix pre-allocated entry/attribute handling
[openldap] / servers / slapd / overlays / constraint.c
index 47d15e8ce81726e62ba8b64c6ecc9286df16d964..7f33dd1cb3f63570ba1f81dfd00fc86a6609805f 100644 (file)
@@ -62,14 +62,14 @@ static ConfigDriver constraint_cf_gen;
 static ConfigTable constraintcfg[] = {
     { "constraint_attribute", "attribute regex <regular expression>",
       4, 4, 0, ARG_MAGIC | CONSTRAINT_ATTRIBUTE, constraint_cf_gen,
-      "( HPcfgOvAt:4.1 NAME 'olcConstraintAttribute' "
+      "( OLcfgOvAt:13.1 NAME 'olcConstraintAttribute' "
       "DESC 'regular expression constraint for attribute' "
       "SYNTAX OMsDirectoryString )", NULL, NULL },
     { NULL, NULL, 0, 0, 0, ARG_IGNORED }
 };
 
 static ConfigOCs constraintocs[] = {
-    { "( HPcfgOvOc:4.1 "
+    { "( OLcfgOvOc:13.1 "
       "NAME 'olcConstraintConfig' "
       "DESC 'Constraint overlay configuration' "
       "SUP olcOverlayConfig "
@@ -137,32 +137,24 @@ constraint_cf_gen( ConfigArgs *c )
                         
                         on->on_bi.bi_private = NULL;
                     } else {
-                        constraint *cpp;
+                        constraint **cpp;
                         
                             /* zap constraint numbered 'valx' */
-                        for(i=0, cp = cn, cpp = NULL;
+                        for(i=0, cp = cn, cpp = &cn;
                             (cp) && (i<c->valx);
-                            i++, cpp = cp, cp=cp->ap_next);
+                            i++, cpp = &cp->ap_next, cp = *cpp);
 
-                        if (cpp) {
+                        if (cp) {
                                 /* zap cp, and join cpp to cp->ap_next */
-                            cpp->ap_next = cp->ap_next;
+                            *cpp = cp->ap_next;
                             if (cp->re) {
                                 regfree(cp->re);
                                 ch_free(cp->re);
                             }
                             if (cp->re_str) ch_free(cp->re_str);
                             ch_free(cp);
-                        } else {
-                                /* zap the list head */
-                            if (cn->re) {
-                                regfree(cn->re);
-                                ch_free(cn->re);
-                            }
-                            if (cn->re_str) ch_free(cn->re_str);
-                            ch_free(cn);
-                            on->on_bi.bi_private = cn->ap_next;
                         }
+                        on->on_bi.bi_private = cn;
                     }
                     
                     break;