From 224721e7f03f2fee72d36f664444543d5f21bc29 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 18 Oct 2021 10:21:47 -0500 Subject: [PATCH] netconfig: Make sure gw is not NULL strcmp behavior is undefined if one of the parameters is NULL. Server-id is a mandatory value and cannot be NULL. Gateway can be NULL in DHCP, so check that explicitly. Reported-by: Andrew Zaborowski --- src/netconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netconfig.c b/src/netconfig.c index c51a1ec2..2ffc5ab1 100644 --- a/src/netconfig.c +++ b/src/netconfig.c @@ -594,7 +594,7 @@ static void netconfig_gateway_to_arp(struct netconfig *netconfig) gw = l_dhcp_lease_get_gateway(lease); server_mac = l_dhcp_lease_get_server_mac(lease); - if (strcmp(server_id, gw) || !server_mac) + if (!gw || strcmp(server_id, gw) || !server_mac) return; l_debug("Gateway MAC is known, setting into ARP cache");