s4:dsdb - we don't need to check if a DN != NULL if we call "ldb_dn_validate"
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 4 Mar 2011 09:44:22 +0000 (10:44 +0100)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Fri, 4 Mar 2011 21:07:24 +0000 (22:07 +0100)
"ldb_dn_validate" is NULL-safe and does the check implicitly.

Reviewed by: Tridge

source4/dsdb/samdb/ldb_modules/simple_ldap_map.c
source4/lib/ldb/pyldb.c
source4/rpc_server/drsuapi/getncchanges.c

index fce45928959a69e1f1cb2956acab36d2834ef8d5..7412d29267d19c6523ac4bc7d0f53069f428d22e 100644 (file)
@@ -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);
        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);
        }
                talloc_free(dn);
                return val_copy(module, ctx, val);
        }
index c1962e612ff9f590c4410cba37004a98e4514122..d14487ba02186daafc606c89f1e903d064025e78 100644 (file)
@@ -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);
        }
 
        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;
                talloc_free(mem_ctx);
                PyErr_SetString(PyExc_ValueError, "unable to parse dn string");
                return NULL;
index b7431b67027a3b1fa02c3980e8ea6f87a013a1ff..8ae536823de22c43e112c24e284397bffe59d114 100644 (file)
@@ -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);
        }
 
        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",
            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);
         */
 
        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)));
                /* 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)));