From 02da9704a05467f7c33e3ade582f62336ff55141 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 6 Mar 2024 14:23:45 +0100 Subject: [PATCH] s3/rpc_client: fix handling of NT_STATUS_SOME_NOT_MAPPED In this case names that couldn't be resolved will be have a NULL sid pointer which would trigger a crash in sid_copy(). Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Ralph Boehme Signed-off-by: Stefan Metzmacher --- source3/rpc_client/cli_lsarpc.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index 73b4872a2c4..cf2572ed61c 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -751,12 +751,23 @@ NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h, } if (use_lookupnames4) { - sid_copy(sid, sid_array3.sids[i].sid); + if (sid_array3.sids[i].sid != NULL) { + sid_copy(sid, sid_array3.sids[i].sid); + } else { + ZERO_STRUCTP(sid); + (*types)[i] = SID_NAME_UNKNOWN; + } } else { - sid_copy(sid, domains->domains[dom_idx].sid); + if (domains->domains[dom_idx].sid != NULL) { + sid_copy(sid, domains->domains[dom_idx].sid); - if (sid_array.sids[i].rid != 0xffffffff) { - sid_append_rid(sid, sid_array.sids[i].rid); + if (sid_array.sids[i].rid != 0xffffffff) { + sid_append_rid(sid, + sid_array.sids[i].rid); + } + } else { + ZERO_STRUCTP(sid); + (*types)[i] = SID_NAME_UNKNOWN; } } -- 2.47.3