diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-10-19 11:20:14 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-10-19 11:22:35 +1100 |
commit | d16fe72585445e7fd3724a7413ca7e03ee633fc9 (patch) | |
tree | 54cc5dacefa7ce1ae1c1c416ed68616d195b88b7 /source4/lib/ldb/common | |
parent | 5f6c004dec2140755ddfe5f801775e19a03a7ec8 (diff) | |
download | samba-d16fe72585445e7fd3724a7413ca7e03ee633fc9.tar.gz samba-d16fe72585445e7fd3724a7413ca7e03ee633fc9.tar.bz2 samba-d16fe72585445e7fd3724a7413ca7e03ee633fc9.zip |
s4-ldb: cope with NULL oid in controls
the ldap server will mark a control with a NULL oid in order to remove
it. This prevents a O(n^2) cost in control handling.
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r-- | source4/lib/ldb/common/ldb.c | 10 | ||||
-rw-r--r-- | source4/lib/ldb/common/ldb_controls.c | 10 |
2 files changed, 11 insertions, 9 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 33d6c48cbe..e2a3e603ce 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -756,10 +756,12 @@ static void ldb_trace_request(struct ldb_context *ldb, struct ldb_request *req) ldb_debug_add(ldb, " control: <NONE>\n"); } else { for (i=0; req->controls && req->controls[i]; i++) { - ldb_debug_add(ldb, " control: %s crit:%u data:%s\n", - req->controls[i]->oid, - req->controls[i]->critical, - req->controls[i]->data?"yes":"no"); + if (req->controls[i]->oid) { + ldb_debug_add(ldb, " control: %s crit:%u data:%s\n", + req->controls[i]->oid, + req->controls[i]->critical, + req->controls[i]->data?"yes":"no"); + } } } diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index a63357de7f..f0afe8a96a 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -41,7 +41,7 @@ struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char if (req->controls != NULL) { for (i = 0; req->controls[i]; i++) { - if (strcmp(oid, req->controls[i]->oid) == 0) { + if (req->controls[i]->oid && strcmp(oid, req->controls[i]->oid) == 0) { break; } } @@ -60,7 +60,7 @@ struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid if (rep->controls != NULL) { for (i = 0; rep->controls[i]; i++) { - if (strcmp(oid, rep->controls[i]->oid) == 0) { + if (rep->controls[i]->oid && strcmp(oid, rep->controls[i]->oid) == 0) { break; } } @@ -170,7 +170,7 @@ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool criti for (n=0; req->controls && req->controls[n];n++) { /* having two controls of the same OID makes no sense */ - if (strcmp(oid, req->controls[n]->oid) == 0) { + if (req->controls[n]->oid && strcmp(oid, req->controls[n]->oid) == 0) { return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; } } @@ -208,7 +208,7 @@ int ldb_reply_add_control(struct ldb_reply *ares, const char *oid, bool critical for (n=0; ares->controls && ares->controls[n];) { /* having two controls of the same OID makes no sense */ - if (strcmp(oid, ares->controls[n]->oid) == 0) { + if (ares->controls[n]->oid && strcmp(oid, ares->controls[n]->oid) == 0) { return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; } n++; @@ -246,7 +246,7 @@ int ldb_request_replace_control(struct ldb_request *req, const char *oid, bool c } for (n=0; req->controls[n];n++) { - if (strcmp(oid, req->controls[n]->oid) == 0) { + if (req->controls[n]->oid && strcmp(oid, req->controls[n]->oid) == 0) { req->controls[n]->critical = critical; req->controls[n]->data = data; return LDB_SUCCESS; |