From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 333005A061C for ; Tue, 17 Nov 2026 13:06:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794917188; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8IEs0nXwHLXKnQYX00f0GA4852rHrp0MsmzsxKYwarw=; b=iIGOizY4YreY/uSCT/wkihIG5bIm/9v5QKLNRq8o5qpVrCtRjtJzQ3emAU3VyqeKmxDTz4 pwvn4kUSOq0hzZTHh8C3sWdrCNcZOsR9NvEWiF5aYai/ybl9ujCHwcjcjz4tN7th6Nxt1D d0LyAj6rabNp1jn2M5S3WJcdmmZ7iDU= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-TYVviDaQNounAcstAi0rkw-1; Tue, 17 Nov 2026 07:06:27 -0500 X-MC-Unique: TYVviDaQNounAcstAi0rkw-1 X-Mimecast-MFC-AGG-ID: TYVviDaQNounAcstAi0rkw_1794917186 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DD122180034F; Tue, 17 Nov 2026 12:06:25 +0000 (UTC) Received: from anskuma-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 89F5630000E3; Tue, 17 Nov 2026 12:06:23 +0000 (UTC) From: Anshu Kumari To: sbrivio@redhat.com, passt-dev@passt.top, eonzylakshitha@gmail.com Subject: [PATCH 1/2] dhcp: Use unsigned int for opts[].slen Date: Tue, 17 Nov 2026 17:36:16 +0530 Message-ID: <20261117120617.663503-2-anskuma@redhat.com> In-Reply-To: <20261117120617.663503-1-anskuma@redhat.com> References: <20261117120617.663503-1-anskuma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: sZq_2rToOud3ty4z0ZTL5pp9FjKRClY0ug7XcbMfLO8_1794917186 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: PMRSN4R32TJSITHWHOZ4QMW7GVYLODDG X-Message-ID-Hash: PMRSN4R32TJSITHWHOZ4QMW7GVYLODDG X-MailFrom: anskuma@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: anskuma@redhat.com X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Anshu Kumari --- 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