s4/ldb - remove now superflous "ldb_dn_validate" checks
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 4 Mar 2011 09:49:47 +0000 (10:49 +0100)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 4 Mar 2011 21:07:24 +0000 (22:07 +0100)
If we immediately afterwards perform an LDB base operation then we don't
need an explicit "ldb_dn_validate" check anymore (only OOM makes sense).

Reviewed by: Tridge

source4/dsdb/common/util.c
source4/dsdb/common/util_samr.c
source4/dsdb/samdb/ldb_modules/rootdse.c
source4/ldap_server/ldap_server.c
source4/lib/ldb/tools/ldbdel.c
source4/lib/ldb/tools/ldbedit.c
source4/lib/ldb/tools/ldbrename.c
source4/lib/ldb/tools/ldbsearch.c
source4/libnet/libnet_join.c

index d0efa057e7b4d7843f43c90a65370a154c5beba4..2563b40ebdb506ae8cee26172b0c0622b11738e5 100644 (file)
@@ -3761,9 +3761,9 @@ int dsdb_search_by_dn_guid(struct ldb_context *ldb,
        int ret;
 
        dn = ldb_dn_new_fmt(tmp_ctx, ldb, "<GUID=%s>", GUID_string(tmp_ctx, guid));
-       if (!ldb_dn_validate(dn)) {
+       if (dn == NULL) {
                talloc_free(tmp_ctx);
-               return LDB_ERR_INVALID_DN_SYNTAX;
+               return ldb_oom(ldb);
        }
 
        ret = dsdb_search_dn(ldb, mem_ctx, _res, dn, attrs, dsdb_flags);
index deaea2e07fa60538c7e4c5cd5fa105ee8c55bff5..7a4f64412360c6d7ce0fbdc36b2ae1f9cc34a404 100644 (file)
@@ -507,7 +507,7 @@ NTSTATUS dsdb_lookup_rids(struct ldb_context *ldb,
                                    dom_sid_string(tmp_ctx,
                                                   dom_sid_add_rid(tmp_ctx, domain_sid,
                                                                   rids[i])));
-               if (!dn || !ldb_dn_validate(dn)) {
+               if (dn == NULL) {
                        talloc_free(tmp_ctx);
                        return NT_STATUS_NO_MEMORY;
                }
index be60d896387e653fafd84fa0ae95714fcfa8ce27..30fa4d9c519bcd65140f32b2952313eba92f3f66 100644 (file)
@@ -103,7 +103,7 @@ static int expand_dn_in_message(struct ldb_module *module, struct ldb_message *m
        }
 
        dn = ldb_dn_new(tmp_ctx, ldb, dn_string);
-       if (!ldb_dn_validate(dn)) {
+       if (dn == NULL) {
                talloc_free(tmp_ctx);
                return ldb_operr(ldb);
        }
index cd90b47b45c134b11dfd4c3cc18a8b6f2b95189e..adcf7bc71d73af818394e07bc90dae0603b17e1e 100644 (file)
@@ -175,7 +175,7 @@ static int ldapsrv_load_limits(struct ldapsrv_connection *conn)
        }
 
        basedn = ldb_dn_new(tmp_ctx, conn->ldb, NULL);
-       if ( ! ldb_dn_validate(basedn)) {
+       if (basedn == NULL) {
                goto failed;
        }
 
index 35d01377083c8399a14a319e79db50eda73b5130..8036d09a70da6d40bb6b69f520235e0a723767ae 100644 (file)
@@ -110,9 +110,8 @@ int main(int argc, const char **argv)
                struct ldb_dn *dn;
 
                dn = ldb_dn_new(ldb, ldb, options->argv[i]);
-               if ( ! ldb_dn_validate(dn)) {
-                       printf("Invalid DN format\n");
-                       return LDB_ERR_INVALID_DN_SYNTAX;
+               if (dn == NULL) {
+                       return LDB_ERR_OPERATIONS_ERROR;
                }
                if (options->recursive) {
                        ret = ldb_delete_recursive(ldb, dn,req_ctrls);
index 8df37060c6581b91fd4bac9d61966ef8190e41e7..36d054e563954df0fe03b2be01742e608056f519 100644 (file)
@@ -326,9 +326,8 @@ int main(int argc, const char **argv)
 
        if (options->basedn != NULL) {
                basedn = ldb_dn_new(ldb, ldb, options->basedn);
-               if ( ! ldb_dn_validate(basedn)) {
-                       printf("Invalid Base DN format\n");
-                       return LDB_ERR_INVALID_DN_SYNTAX;
+               if (basedn == NULL) {
+                       return LDB_ERR_OPERATIONS_ERROR;
                }
        }
 
index e8f67500fc62ee405a19d9e4d06104a1d42a202a..9bbd1f06b1a9b753fb0b64f161f1851386e41685 100644 (file)
@@ -66,9 +66,8 @@ int main(int argc, const char **argv)
 
        dn1 = ldb_dn_new(ldb, ldb, options->argv[0]);
        dn2 = ldb_dn_new(ldb, ldb, options->argv[1]);
-       if ((!ldb_dn_validate(dn1)) || (!ldb_dn_validate(dn2))) {
-               printf("Invalid DN format(s)\n");
-               return LDB_ERR_INVALID_DN_SYNTAX;
+       if ((dn1 == NULL) || (dn2 == NULL)) {
+               return LDB_ERR_OPERATIONS_ERROR;
        }
 
        ret = ldb_rename(ldb, dn1, dn2);
index 8c101719a3b598ca40fe1393685ff7f9683a929d..d10b9650daf9882c19a0b2df25aa9c2d81638fb2 100644 (file)
@@ -297,9 +297,8 @@ int main(int argc, const char **argv)
 
        if (options->basedn != NULL) {
                basedn = ldb_dn_new(ldb, ldb, options->basedn);
-               if ( ! ldb_dn_validate(basedn)) {
-                       fprintf(stderr, "Invalid Base DN format\n");
-                       return LDB_ERR_INVALID_DN_SYNTAX;
+               if (basedn == NULL) {
+                       return LDB_ERR_OPERATIONS_ERROR;
                }
        }
 
index 715f21b9895e724e8a014272c9ec5ed2de673781..6e76df43e3d6d6b8d2f02f2cb92e12ea2b985078 100644 (file)
@@ -236,7 +236,7 @@ static NTSTATUS libnet_JoinADSDomain(struct libnet_context *ctx, struct libnet_J
        }
 
        account_dn = ldb_dn_new(tmp_ctx, remote_ldb, account_dn_str);
-       if (! ldb_dn_validate(account_dn)) {
+       if (account_dn == NULL) {
                r->out.error_string = talloc_asprintf(r, "Invalid account dn: %s",
                                                      account_dn_str);
                talloc_free(tmp_ctx);