winbindd: Do not segfault if the trusted domain has no SID
authorAndrew Bartlett <abartlet@samba.org>
Sun, 10 Aug 2014 23:47:54 +0000 (11:47 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sun, 31 Aug 2014 22:36:42 +0000 (00:36 +0200)
Currently we abort, as skipping the domain would make the loop much more complex for a situation not yet seen in the real world.

Andrew Bartlett

Change-Id: Ie1e269eb25047d662d8fd0f771ee20de1d48706b
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-By: Jelmer Vernooij <jelmer@samba.org>
source3/winbindd/winbindd_rpc.c

index 85b3d5c08e532651990974f8d826bc3b09e28602..7a80237e6922fe73a5dd7417adcbdb97789b181c 100644 (file)
@@ -1041,13 +1041,21 @@ NTSTATUS rpc_trusted_domains(TALLOC_CTX *mem_ctx,
                                                                  &dom_list_ex.domains[i].netbios_name.string);
                                trust->dns_name = talloc_move(array,
                                                              &dom_list_ex.domains[i].domain_name.string);
-
+                               if (dom_list_ex.domains[i].sid == NULL) {
+                                       DEBUG(0, ("Trusted Domain %s has no SID, aborting!\n", trust->dns_name));
+                                       return NT_STATUS_INVALID_NETWORK_RESPONSE;
+                               }
                                sid_copy(sid, dom_list_ex.domains[i].sid);
                        } else {
                                trust->netbios_name = talloc_move(array,
                                                                  &dom_list.domains[i].name.string);
                                trust->dns_name = NULL;
 
+                               if (dom_list.domains[i].sid == NULL) {
+                                       DEBUG(0, ("Trusted Domain %s has no SID, aborting!\n", trust->netbios_name));
+                                       return NT_STATUS_INVALID_NETWORK_RESPONSE;
+                               }
+
                                sid_copy(sid, dom_list.domains[i].sid);
                        }