public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Anshu Kumari <anskuma@redhat.com>
To: sbrivio@redhat.com, passt-dev@passt.top, eonzylakshitha@gmail.com
Cc: anskuma@redhat.com
Subject: [PATCH 2/2] dhcp: Add bounds check on DNS search domain option buffer
Date: Tue, 17 Nov 2026 17:36:17 +0530	[thread overview]
Message-ID: <20261117120617.663503-3-anskuma@redhat.com> (raw)
In-Reply-To: <20261117120617.663503-1-anskuma@redhat.com>

Add an explicit check that the encoded DNS search domain data
does not exceed the capacity of opts[119].s before each memcpy()
in opt_set_dns_search().

Reported-by: Lakshitha Perera <eonzylakshitha@gmail.com>
Signed-off-by: Anshu Kumari <anskuma@redhat.com>
---
 dhcp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/dhcp.c b/dhcp.c
index de6b133b..81833368 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -728,6 +728,9 @@ static void opt_set_dns_search(const struct ctx *c, size_t max_len)
 		if (n >= max_len)
 			break;
 
+		if (opts[119].slen + n > sizeof(opts[119].s))
+			break;
+
 		memcpy(opts[119].s + opts[119].slen, buf, n);
 		opts[119].slen += n;
 		max_len -= n;
-- 
2.55.0


  parent reply	other threads:[~2026-11-17 12:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 12:06 [PATCH 0/2] dhcp: Harden DNS search domain option handling Anshu Kumari
2026-11-17 12:06 ` [PATCH 1/2] dhcp: Use unsigned int for opts[].slen Anshu Kumari
2026-11-17 12:06 ` Anshu Kumari [this message]
2026-11-17 12:22 ` [PATCH 0/2] dhcp: Harden DNS search domain option handling Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117120617.663503-3-anskuma@redhat.com \
    --to=anskuma@redhat.com \
    --cc=eonzylakshitha@gmail.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).