Skip to contentSkip to conversation

gdhcp: Do not process missing DHCP_SERVER_ID fields

PATCH In review Daniel Wagner 1 participant 2 messages Jul 26, 2021 – Jul 28, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gdhcp: Do not process missing DHCP_SERVER_ID fields

The DHCP might send an invalid DHCP response with a missing DHCP_SERVER_ID field. In this case just abort the processing and return to the idle loop.

Reported by Mike Evdokimov.

---
 gdhcp/client.c | 5 +++++
 1 file changed, 5 insertions(+)
gdhcp/client.c +5 -0
index c7b85e58e2be..3016dfc2582b 100644
@@ -2381,6 +2381,9 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
 		dhcp_client->retry_times = 0;
 
 		option = dhcp_get_option(&packet, pkt_len, DHCP_SERVER_ID);
+		if (!option)
+			return TRUE;
+
 		dhcp_client->server_ip = get_be32(option);
 		dhcp_client->requested_ip = ntohl(packet.yiaddr);
 
@@ -2442,6 +2445,8 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
 			if (dhcp_client->state == REBOOTING) {
 				option = dhcp_get_option(&packet, pkt_len,
 							DHCP_SERVER_ID);
+				if (!option)
+					return TRUE;
 				dhcp_client->server_ip = get_be32(option);
 			}
 
Signature · 1 line
2.32.0
#1 lore raw
Quoted 5 lines · Daniel Wagner

The DHCP might send an invalid DHCP response with a missing DHCP_SERVER_ID field. In this case just abort the processing and return to the idle loop.

Reported by Mike Evdokimov.

Patch applied.