return true;
}
-static const char *mailslot_name(TALLOC_CTX *mem_ctx, struct in_addr dc_ip)
+static char *mailslot_name(TALLOC_CTX *mem_ctx, struct in_addr dc_ip)
{
return talloc_asprintf(mem_ctx, "%s%X",
NBT_MAILSLOT_GETDC, dc_ip.s_addr);
const char **dc_name,
struct netlogon_samlogon_response **samlogon_response)
{
- struct packet_struct *packet;
- const char *my_mailslot = NULL;
+ struct packet_struct *packet = NULL;
+ char *my_mailslot = NULL;
struct in_addr dc_ip;
DATA_BLOB blob;
- struct netlogon_samlogon_response *r;
+ struct netlogon_samlogon_response *r = NULL;
union dgram_message_body p;
enum ndr_err_code ndr_err;
NTSTATUS status;
if (blob.length < 4) {
DEBUG(0,("invalid length: %d\n", (int)blob.length));
- return false;
+ goto fail;
}
if (RIVAL(blob.data,0) != DGRAM_SMB) {
DEBUG(0,("invalid packet\n"));
- return false;
+ goto fail;
}
blob.data += 4;
(ndr_pull_flags_fn_t)ndr_pull_dgram_smb_packet);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
DEBUG(0,("failed to parse packet\n"));
- return false;
+ goto fail;
}
if (p.smb.smb_command != SMB_TRANSACTION) {
DEBUG(0,("invalid smb_command: %d\n", p.smb.smb_command));
- return false;
+ goto fail;
}
if (DEBUGLEVEL >= 10) {
r = TALLOC_ZERO_P(mem_ctx, struct netlogon_samlogon_response);
if (!r) {
- return false;
+ goto fail;
}
status = pull_netlogon_samlogon_response(&blob, mem_ctx, r);
if (!NT_STATUS_IS_OK(status)) {
- TALLOC_FREE(r);
- return false;
+ goto fail;
}
map_netlogon_samlogon_response(r);
if (!strequal(returned_domain, domain_name)) {
DEBUG(3, ("GetDC: Expected domain %s, got %s\n",
domain_name, returned_domain));
- TALLOC_FREE(r);
- return false;
+ goto fail;
}
*dc_name = talloc_strdup(mem_ctx, returned_dc);
if (!*dc_name) {
- TALLOC_FREE(r);
- return false;
+ goto fail;
}
if (**dc_name == '\\') *dc_name += 1;
DEBUG(10, ("GetDC gave name %s for domain %s\n",
*dc_name, returned_domain));
+ free_packet(packet);
+ TALLOC_FREE(my_mailslot);
return True;
+
+fail:
+ TALLOC_FREE(my_mailslot);
+ TALLOC_FREE(r);
+ if (packet != NULL) {
+ free_packet(packet);
+ }
+ return false;
}