git: 267910463a20 - main - bootpd: clamp the DHCP reply length to the packet buffer
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Nov 2026 05:54:53 UTC
The branch main has been updated by nprice:
URL: https://cgit.FreeBSD.org/src/commit/?id=267910463a20cd74a93bcdd129e36ded09faf1c8
commit 267910463a20cd74a93bcdd129e36ded09faf1c8
Author: Nick Price <nprice@FreeBSD.org>
AuthorDate: 2026-11-24 05:54:18 +0000
Commit: Nick Price <nprice@FreeBSD.org>
CommitDate: 2026-11-24 05:54:29 +0000
bootpd: clamp the DHCP reply length to the packet buffer
A client could set the DHCP maximum-message-size option to a large
value; dovend_rfc1048() derived the reply length from it with no upper
bound, so the trailing bzero() of the vendor area ran far past the
MAX_MSG_SIZE packet buffer. A value >= 0x8000 read into a signed short
instead went negative and slipped past the length clamps, leaving
sendto() to read a huge length from the buffer.
Read msgsz unsigned and clamp the reply length to the buffer size.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D61009
Signed-off-by: Nick Price <nprice@FreeBSD.org>
---
libexec/bootpd/bootpd.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libexec/bootpd/bootpd.c b/libexec/bootpd/bootpd.c
index f73671dab074..31e1967884ad 100644
--- a/libexec/bootpd/bootpd.c
+++ b/libexec/bootpd/bootpd.c
@@ -1250,7 +1250,7 @@ dovend_rfc1048(struct bootp *bp, struct host *hp, int32 bootsize)
{
byte *p, *ep;
byte tag, len;
- short msgsz = 0;
+ u_short msgsz = 0;
p = vp + 4;
ep = p + BP_VEND_LEN - 4;
@@ -1289,6 +1289,10 @@ dovend_rfc1048(struct bootp *bp, struct host *hp, int32 bootsize)
report(LOG_ERR, "invalid response length=%d", pktlen);
pktlen = sizeof(*bp);
}
+ if (pktlen > MAX_MSG_SIZE) {
+ report(LOG_ERR, "response length=%d exceeds buffer", pktlen);
+ pktlen = MAX_MSG_SIZE;
+ }
bytesleft = ((byte*)bp + pktlen) - vp;
if (pktlen > sizeof(*bp)) {
if (debug > 1)