From a23f8a5ccd0f05d4e103a0de8c53c488b1567dfd Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 24 Jul 2017 12:13:50 +0200 Subject: [PATCH 1/2] s4:kcc: Add a NULL check before qsort() This fixes building with GCC 7.1.1 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit 314cf608932c21d593afd04769b07435bcd4fc53) --- source4/dsdb/kcc/kcc_topology.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source4/dsdb/kcc/kcc_topology.c b/source4/dsdb/kcc/kcc_topology.c index cd4dcc55495..0e136ed7936 100644 --- a/source4/dsdb/kcc/kcc_topology.c +++ b/source4/dsdb/kcc/kcc_topology.c @@ -2445,6 +2445,10 @@ static NTSTATUS kcctpl_kruskal(TALLOC_CTX *mem_ctx, struct kcctpl_graph *graph, uint32_t i, num_expected_tree_edges, cst_edges; struct kcctpl_multi_edge_list output_edges; + if (internal_edges.data == NULL || internal_edges.count == 0) { + return NT_STATUS_INVALID_PARAMETER; + } + num_expected_tree_edges = 0; for (i = 0; i < graph->vertices.count; i++) { struct kcctpl_vertex *vertex = &graph->vertices.data[i]; -- 2.13.3 From 9384a8f2159d47202a9fa2f054511438aeeeb5b7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 24 Jul 2017 12:19:27 +0200 Subject: [PATCH 2/2] mit-kdb: Fix NULL pointer check after malloc This fixes building with GCC 7.1. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit 9b64b11c2f2c1bc77ae887b34d7efcb9f1452da7) --- source4/kdc/mit-kdb/kdb_samba_pac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/kdc/mit-kdb/kdb_samba_pac.c b/source4/kdc/mit-kdb/kdb_samba_pac.c index 0ab8c372e0e..15497603b10 100644 --- a/source4/kdc/mit-kdb/kdb_samba_pac.c +++ b/source4/kdc/mit-kdb/kdb_samba_pac.c @@ -87,7 +87,7 @@ krb5_error_code kdb_samba_dbekd_encrypt_key_data(krb5_context context, key_data->key_data_kvno = keyver; key_data->key_data_type[0] = kkey->enctype; key_data->key_data_contents[0] = malloc(kkey->length); - if (key_data->key_data_contents[0]) { + if (key_data->key_data_contents[0] == NULL) { return ENOMEM; } memcpy(key_data->key_data_contents[0], -- 2.13.3