From 349b9b72ec36194a1275eaa42ca145071256b623 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Matthias=20Dieter=20Walln=C3=B6fer?= Date: Fri, 4 Mar 2011 10:44:22 +0100 Subject: [PATCH] s4:dsdb - we don't need to check if a DN != NULL if we call "ldb_dn_validate" "ldb_dn_validate" is NULL-safe and does the check implicitly. Reviewed by: Tridge --- source4/dsdb/samdb/ldb_modules/simple_ldap_map.c | 2 +- source4/lib/ldb/pyldb.c | 3 +-- source4/rpc_server/drsuapi/getncchanges.c | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c index fce45928959..7412d29267d 100644 --- a/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c +++ b/source4/dsdb/samdb/ldb_modules/simple_ldap_map.c @@ -147,7 +147,7 @@ static struct ldb_val objectCategory_always_dn(struct ldb_module *module, TALLOC const struct ldb_schema_attribute *a = ldb_schema_attribute_by_name(ldb, "objectCategory"); dn = ldb_dn_from_ldb_val(ctx, ldb, val); - if (dn && ldb_dn_validate(dn)) { + if (ldb_dn_validate(dn)) { talloc_free(dn); return val_copy(module, ctx, val); } diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index c1962e612ff..d14487ba021 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -553,8 +553,7 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa } ret = ldb_dn_new(mem_ctx, ldb_ctx, str); - - if (ret == NULL || !ldb_dn_validate(ret)) { + if (!ldb_dn_validate(ret)) { talloc_free(mem_ctx); PyErr_SetString(PyExc_ValueError, "unable to parse dn string"); return NULL; diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c index b7431b67027..8ae536823de 100644 --- a/source4/rpc_server/drsuapi/getncchanges.c +++ b/source4/rpc_server/drsuapi/getncchanges.c @@ -621,8 +621,7 @@ static WERROR getncchanges_rid_alloc(struct drsuapi_bind_state *b_state, } req_dn = drs_ObjectIdentifier_to_dn(mem_ctx, ldb, req10->naming_context); - if (!req_dn || - !ldb_dn_validate(req_dn) || + if (!ldb_dn_validate(req_dn) || ldb_dn_compare(req_dn, rid_manager_dn) != 0) { /* that isn't the RID Manager DN */ DEBUG(0,(__location__ ": RID Alloc request for wrong DN %s\n", @@ -964,8 +963,7 @@ static WERROR getncchanges_change_master(struct drsuapi_bind_state *b_state, */ req_dn = drs_ObjectIdentifier_to_dn(mem_ctx, ldb, req10->naming_context); - if (!req_dn || - !ldb_dn_validate(req_dn)) { + if (!ldb_dn_validate(req_dn)) { /* that is not a valid dn */ DEBUG(0,(__location__ ": FSMO role transfer request for invalid DN %s\n", drs_ObjectIdentifier_to_string(mem_ctx, req10->naming_context))); -- 2.34.1