From 30e05d607235edffcde51aafe19707045f300b96 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 26 Jan 2018 00:38:32 +0100 Subject: [PATCH] s4:torture: zero initialize variables in test_LookupSidsReply() This avoids crashes if the server returns unexpected results. The test should just report the failure in that case. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13282 Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme (cherry picked from commit 7b86b94c71268cdab434ced74caedcdd5eb20e12) --- source4/torture/rpc/lsa_lookup.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source4/torture/rpc/lsa_lookup.c b/source4/torture/rpc/lsa_lookup.c index 59decda1710..f641827e6dc 100644 --- a/source4/torture/rpc/lsa_lookup.c +++ b/source4/torture/rpc/lsa_lookup.c @@ -329,9 +329,9 @@ bool torture_rpc_lsa_lookup(struct torture_context *torture) static bool test_LookupSidsReply(struct torture_context *tctx, struct dcerpc_pipe *p) { - struct policy_handle *handle; + struct policy_handle *handle = NULL; - struct dom_sid **sids; + struct dom_sid **sids = NULL; uint32_t num_sids = 1; struct lsa_LookupSids r; @@ -346,6 +346,10 @@ static bool test_LookupSidsReply(struct torture_context *tctx, struct dcerpc_binding_handle *b = p->binding_handle; enum dcerpc_transport_t transport = dcerpc_binding_get_transport(p->binding); + ZERO_STRUCT(r); + ZERO_STRUCT(sidarray); + ZERO_STRUCT(names); + if (transport != NCACN_NP && transport != NCALRPC) { torture_comment(tctx, "test_LookupSidsReply is only available " @@ -359,7 +363,7 @@ static bool test_LookupSidsReply(struct torture_context *tctx, dom_admin_sid = talloc_asprintf(tctx, "%s-%d", dom_sid, 512); - sids = talloc_array(tctx, struct dom_sid *, num_sids); + sids = talloc_zero_array(tctx, struct dom_sid *, num_sids); sids[0] = dom_sid_parse_talloc(tctx, dom_admin_sid); @@ -367,7 +371,7 @@ static bool test_LookupSidsReply(struct torture_context *tctx, names.names = NULL; sidarray.num_sids = num_sids; - sidarray.sids = talloc_array(tctx, struct lsa_SidPtr, num_sids); + sidarray.sids = talloc_zero_array(tctx, struct lsa_SidPtr, num_sids); for (i=0; i