From 7de96133858edee309102976fd7265d6e480e778 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 17 Feb 2018 17:11:41 +0100 Subject: [PATCH] nbt_server: Centralize a consistency check This is a "should NEVER happen" and applies to both LOGON_PRIMARY_QUERY and LOGON_SAM_LOGON_REQUEST Signed-off-by: Volker Lendecke Reviewed-by: Andreas Schneider --- source4/nbt_server/dgram/netlogon.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c index 5ed3223ddf2..ede3e77c965 100644 --- a/source4/nbt_server/dgram/netlogon.c +++ b/source4/nbt_server/dgram/netlogon.c @@ -113,17 +113,10 @@ static NTSTATUS nbtd_netlogon_samlogon( { struct nbt_name *name = &packet->data.msg.dest_name; struct ldb_context *samctx; - struct nbtd_interface *reply_iface = nbtd_find_reply_iface(iface, src->addr, false); - const char *my_ip = reply_iface->ip_address; struct dom_sid *sid; struct nbt_netlogon_response *response; NTSTATUS status; - if (!my_ip) { - DEBUG(0, ("Could not obtain own IP address for datagram socket\n")); - return NT_STATUS_NOT_SUPPORTED; - } - /* only answer getdc requests on the PDC or LOGON names */ if (name->type != NBT_NAME_PDC && name->type != NBT_NAME_LOGON) { return NT_STATUS_NOT_SUPPORTED; @@ -170,13 +163,19 @@ void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot, NTSTATUS status = NT_STATUS_NO_MEMORY; struct nbtd_interface *iface = talloc_get_type(dgmslot->private_data, struct nbtd_interface); - struct nbt_netlogon_packet *netlogon; + struct nbt_netlogon_packet *netlogon = NULL; struct nbtd_interface *reply_iface = nbtd_find_reply_iface( iface, src->addr, false); struct nbtd_iface_name *iname; struct nbt_name *name = &packet->data.msg.dest_name; struct nbt_netlogon_response *response; + if (reply_iface->ip_address == NULL) { + DBG_WARNING("Could not obtain own IP address for datagram " + "socket\n"); + goto failed; + } + netlogon = talloc(dgmslot, struct nbt_netlogon_packet); if (netlogon == NULL) { goto failed; -- 2.11.4.GIT