]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:kcc: Add a NULL check before qsort()
authorAndreas Schneider <asn@samba.org>
Thu, 21 Jun 2018 09:11:58 +0000 (11:11 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 27 Jun 2018 12:52:13 +0000 (14:52 +0200)
../source4/dsdb/kcc/kcc_topology.c: In function ‘kcctpl_get_all_bridgehead_dcs.constprop’:
../source4/dsdb/kcc/kcc_topology.c:1330:3: error: argument 1 null where non-null expected [-Werror=nonnull]
   qsort(bridgeheads.data, bridgeheads.count,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(v4-7-test): Karolin Seeger <kseeger@samba.org>
Autobuild-Date(v4-7-test): Wed Jun 27 14:52:13 CEST 2018 on sn-devel-144

source4/dsdb/kcc/kcc_topology.c

index 0e136ed79363a32ecdab3387d61a6ecd00a6eea6..de69f0ab0e37f146235c6c156a7a591cd4b859c5 100644 (file)
@@ -1327,6 +1327,11 @@ static NTSTATUS kcctpl_get_all_bridgehead_dcs(struct kccsrv_service *service,
        }
 
        if (site_opts & NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED) {
+               if (bridgeheads.data == NULL || bridgeheads.count == 0) {
+                       talloc_free(tmp_ctx);
+                       return NT_STATUS_INVALID_PARAMETER;
+               }
+
                qsort(bridgeheads.data, bridgeheads.count,
                      sizeof(struct ldb_message), kcctpl_sort_bridgeheads);
        } else {