CVE-2018-1140 Add NULL check for ldb_dn_get_casefold() in ltdb_index_dn_attr()
authorAndrej Gessel <Andrej.Gessel@janztec.com>
Fri, 6 Apr 2018 16:18:33 +0000 (18:18 +0200)
committerKarolin Seeger <kseeger@samba.org>
Sat, 11 Aug 2018 06:16:03 +0000 (08:16 +0200)
Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374

lib/ldb/ldb_tdb/ldb_index.c

index 40baeea5c2bc4b22375c6bbb7e98f4c040d15ef9..682469396ce2ea12df3eb2c932fba502c7709f92 100644 (file)
@@ -1405,6 +1405,15 @@ static int ltdb_index_dn_attr(struct ldb_module *module,
 
        /* work out the index key from the parent DN */
        val.data = (uint8_t *)((uintptr_t)ldb_dn_get_casefold(dn));
+       if (val.data == NULL) {
+               const char *dn_str = ldb_dn_get_linearized(dn);
+               ldb_asprintf_errstring(ldb_module_get_ctx(module),
+                                      __location__
+                                      ": Failed to get casefold DN "
+                                      "from: %s",
+                                      dn_str);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
        val.length = strlen((char *)val.data);
        key = ltdb_index_key(ldb, ltdb, attr, &val, NULL);
        if (!key) {