Fix segfault in the very rare case when we are not able to find the rootnamingcontext
authorMatthieu Patou <mat@matws.net>
Sat, 23 May 2015 07:02:42 +0000 (00:02 -0700)
committerMatthieu Patou <mat@samba.org>
Wed, 27 May 2015 16:40:35 +0000 (18:40 +0200)
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Change-Id: I96fd5c7f39280090d5ec1dcdcb445fd7a44bd1c6

Autobuild-User(master): Matthieu Patou <mat@samba.org>
Autobuild-Date(master): Wed May 27 18:40:35 CEST 2015 on sn-devel-104

source4/dsdb/common/util.c

index 7b948f2d81f333f82cc986bc3290ca3b62ac38a2..2b7d4926392ebe9e7bc47b8e76a7578ea5691c8a 100644 (file)
@@ -3468,7 +3468,7 @@ int dsdb_find_nc_root(struct ldb_context *samdb, TALLOC_CTX *mem_ctx, struct ldb
 
        ret = ldb_search(samdb, tmp_ctx, &root_res,
                         ldb_dn_new(tmp_ctx, samdb, ""), LDB_SCOPE_BASE, root_attrs, NULL);
-       if (ret != LDB_SUCCESS) {
+       if (ret != LDB_SUCCESS || root_res->count == 0) {
                DEBUG(1,("Searching for namingContexts in rootDSE failed: %s\n", ldb_errstring(samdb)));
                talloc_free(tmp_ctx);
                return ret;