don't allow two controls to be added with the same OID
authorAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 03:33:37 +0000 (13:33 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 2 Sep 2009 08:19:55 +0000 (18:19 +1000)
Two controls with the same OID makes no sense, as they may
have different data attached

source4/lib/ldb/common/ldb_controls.c

index 3c2ef5ea0025a4b1aa9abbdf841a725e8c819cb5..b38373ec12f38543d6886eefd30959fdbb90efaa 100644 (file)
@@ -127,7 +127,13 @@ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool criti
        struct ldb_control **ctrls;
        struct ldb_control *ctrl;
 
-       for (n=0; req->controls && req->controls[n];) { n++; }
+       for (n=0; req->controls && req->controls[n];) { 
+               /* having two controls of the same OID makes no sense */
+               if (strcmp(oid, req->controls[n]->oid) == 0) {
+                       return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
+               }
+               n++; 
+       }
 
        ctrls = talloc_realloc(req, req->controls,
                               struct ldb_control *,