nbt_server: Centralize a consistency check
authorVolker Lendecke <vl@samba.org>
Sat, 17 Feb 2018 16:11:41 +0000 (17:11 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 27 Feb 2018 08:14:17 +0000 (09:14 +0100)
This is a "should NEVER happen" and applies to both
LOGON_PRIMARY_QUERY and LOGON_SAM_LOGON_REQUEST

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/nbt_server/dgram/netlogon.c

index 5ed3223ddf275a4265786fb8d73ea27660812334..ede3e77c9653529b0542cbdee31e1740de6d477c 100644 (file)
@@ -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;