From: Andrej Gessel Date: Fri, 6 Apr 2018 16:18:33 +0000 (+0200) Subject: CVE-2018-1140 Add NULL check for ldb_dn_get_casefold() in ltdb_index_dn_attr() X-Git-Tag: ldb-1.5.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0998f2f1bced019db4000ef4b55887abcb65f6d2;p=thirdparty%2Fsamba.git CVE-2018-1140 Add NULL check for ldb_dn_get_casefold() in ltdb_index_dn_attr() Signed-off-by: Andrej Gessel Reviewed-by: Douglas Bagnall Reviewed-by: Andrew Bartlett BUG: https://bugzilla.samba.org/show_bug.cgi?id=13374 --- diff --git a/lib/ldb/ldb_key_value/ldb_kv_index.c b/lib/ldb/ldb_key_value/ldb_kv_index.c index 550f4b620ad..fda55dd548f 100644 --- a/lib/ldb/ldb_key_value/ldb_kv_index.c +++ b/lib/ldb/ldb_key_value/ldb_kv_index.c @@ -1613,6 +1613,15 @@ static int ldb_kv_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 = ldb_kv_index_key(ldb, ldb_kv, attr, &val, NULL, truncation); if (!key) {