Skip to content

Commit 2f51e43

Browse files
committed
dhcp: message must be large enough for a DHCP cookie
1 parent 8a16e69 commit 2f51e43

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/dhcp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,8 @@ dhcp_readudp0(struct dhcp_ctx *ctx, int fd, unsigned short events)
16541654
return;
16551655
}
16561656

1657-
if ((size_t)nread < offsetof(struct bootp, vend)) {
1657+
/* Must at least have enough for the DHCP cookie */
1658+
if ((size_t)nread < offsetof(struct bootp, vend) + sizeof(uint32_t)) {
16581659
logerrx("dhcp: truncated packet (%zu) from %s", nread,
16591660
inet_ntoa(from.sin_addr));
16601661
return;
@@ -1663,8 +1664,10 @@ dhcp_readudp0(struct dhcp_ctx *ctx, int fd, unsigned short events)
16631664
bootp = ctx->dhcp_udp_buf;
16641665
ifp = if_findifpfromcmsg(ctx->dhcp_ctx, &msg, NULL);
16651666
if (ifp == NULL) {
1666-
logwarnx("dhcp: interface not found 0x%x %s", bootp->xid,
1667+
#if 0
1668+
logerrx("dhcp: interface not found 0x%x %s", bootp->xid,
16671669
inet_ntoa(from.sin_addr));
1670+
#endif
16681671
return;
16691672
}
16701673

0 commit comments

Comments
 (0)