From: Anshu Kumari <anskuma@redhat.com>
To: sbrivio@redhat.com, passt-dev@passt.top, eonzylakshitha@gmail.com
Cc: anskuma@redhat.com
Subject: [PATCH 1/2] dhcp: Use unsigned int for opts[].slen
Date: Tue, 17 Nov 2026 17:36:16 +0530 [thread overview]
Message-ID: <20261117120617.663503-2-anskuma@redhat.com> (raw)
In-Reply-To: <20261117120617.663503-1-anskuma@redhat.com>
Now that negative value (-1) is no longer used to do the
opts[].slen initialization (removed by commit 64e69136ecbc,
"dhcp: Add option configuration tracking with enum opt_conf"),
change slen from int to unsigned int. Hence, removed the
explicit (size_t) casts in comparisons.
Reported-by: Lakshitha Perera <eonzylakshitha@gmail.com>
Signed-off-by: Anshu Kumari <anskuma@redhat.com>
---
dhcp.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/dhcp.c b/dhcp.c
index a081e34f..de6b133b 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -70,7 +70,7 @@ enum opt_conf {
*/
struct opt {
int sent;
- int slen;
+ unsigned int slen;
int clen;
enum opt_conf conf;
uint8_t c[255];
@@ -529,13 +529,13 @@ static size_t fill_split_areas(struct msg *m, size_t opt_size, int o,
written = fill_split(m->o, opt_size, o, opt_off,
opts[o].s, opts[o].slen, dry_run);
- if (written < (size_t)opts[o].slen && !has_bootfile) {
+ if (written < opts[o].slen && !has_bootfile) {
written += fill_split(m->file, sizeof(m->file) - 1, o,
file_off,
opts[o].s + written,
opts[o].slen - written, dry_run);
}
- if (written < (size_t)opts[o].slen) {
+ if (written < opts[o].slen) {
written += fill_split(m->sname, sizeof(m->sname) - 1, o,
sname_off,
opts[o].s + written,
@@ -610,7 +610,7 @@ static int fill(struct msg *m, bool has_bootfile)
&dry_sname_off,
has_bootfile, true);
- if (total < (size_t)opts[o].slen) {
+ if (total < opts[o].slen) {
debug("DHCP: skipping option %i (no space)", o);
continue;
}
@@ -620,7 +620,7 @@ static int fill(struct msg *m, bool has_bootfile)
&offset, &file_off, &sname_off,
has_bootfile, false);
- if (written >= (size_t)opts[o].slen)
+ if (written >= opts[o].slen)
opts[o].sent = 1;
}
@@ -690,7 +690,7 @@ static int opt_dns_search_dup_ptr(unsigned char *buf, const char *cmp,
static void opt_set_dns_search(const struct ctx *c, size_t max_len)
{
char buf[NS_MAXDNAME];
- int i;
+ unsigned int i;
opts[119].slen = 0;
@@ -954,8 +954,8 @@ int dhcp(const struct ctx *c, struct iov_tail *data)
/* RFC 2132, Section 9.5: put boot file name in the 'file' header
* field. Reserve the file field from overload.
*/
- has_bootfile = opts[67].slen > 0 &&
- (size_t)opts[67].slen < sizeof(reply.file);
+ has_bootfile = opts[67].slen &&
+ opts[67].slen < sizeof(reply.file);
dlen = offsetof(struct msg, o) + fill(&reply, has_bootfile);
--
2.55.0
next prev 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 ` Anshu Kumari [this message]
2026-11-17 12:06 ` [PATCH 2/2] dhcp: Add bounds check on DNS search domain option buffer Anshu Kumari
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-2-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).