From nobody Wed Nov 11 19:46:00 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jPvCF3Cf2z70fp4 for ; Wed, 11 Nov 2026 19:46:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jPvCF0Fq4z4KmY for ; Wed, 11 Nov 2026 19:46:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794426361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ld54+LUihZQ/Kr9b7SrzQFfnYuy0giYujcCDIzCC43U=; b=nDMzF7c7l4gYRqBdnFLW6h1Yc9lwNmdzKtainzkOZo2hradyPvmbTqvk1pt/ovYl6gUA9z w1AmrxrCzwxKpuLCQ8Zid/qchMwlhSs5l6LxazinzlJsQyH+QeR8uRKUl47RV1r3NdB3I/ oQm3FhCa10A60JyJY456IJRDDFz9wrgAZWwsNrI+ZzH2Fat9/nAsFJyX9A447tMePVDX+Z mdKQMwtUsWYxHS3kt2dkMvB0NjaJ7PMQTxajLEj+zZjyUiKJW33bitdAhksujYmspuS7lY WLCVByZUB9cA04TT8GYHJgWR5Q0rwpoTrZFja7xmDUC2aJbzyWHhWQ1L4ejCYA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794426361; b=ydhAC+KKsf9cuQpLlZLLfPY9+0objW69iLJdQ8UxvwfCXKIM5K9H7CyQ1ADSU1L8dRfBLp OxRF1pVhXhlLZkMsdcEoRax8VR1j7TAPgFyo+pIZ4O50uU0lDGoa9r+ooFOX17ZaJMLU/Z tjiZxFFz4t8fZSfiirMkZz3koJKz5jVm2zhDjkNvqz+b5KwQ0Uy1m/sEKOA8HMMOvC6jBY f/A6S0++/GJtRcwT9dGZ7n52GGfmlWoS2xYTyPGcrbnoXmffyNhP9q4VWiO2JLugkV/VTB tCtl6GlDsUyyLsmDFrtk62NwFkfeEJldbOlXgCcMBRzp36VnfgFFZDy1KxnsoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794426361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ld54+LUihZQ/Kr9b7SrzQFfnYuy0giYujcCDIzCC43U=; b=Pz4fWXvxEmOBT3j+nJ5Oa2bvbTSqIQaUuMmSVjmhZKEZy+ZKnAcSpjZ8Kl2Wvw4myhC2DA RwOnAlEP8ygMcd5de1y6fv2bqvrFMiO2yBKXZV2LOiw0pL/3XPGpPgJryYAPzAvszalF59 Ov9o3FdN3EmXOZehcU7GOuHSimvDmUYLuaeHh7L2hS20CcmwGbxC8pHerLGulMjBT1OLtH DmcMa+ohy3vy9RxdZ/Fnl//pIpumRms3fQUTqHbewfXeMbl9WeLO+EisozEBgZ/aK4W2uT 4RD8MkBQ0PX3wd0mqtF933oHhGkX4qZc4vY3nfgO3fB+DZFVADTsasPKjX5m2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jPvCD6mL0zSlF for ; Wed, 11 Nov 2026 19:46:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 8984 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 11 Nov 2026 19:46:00 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 14541ca2bf37 - main - tftpd: Fix off-by-one in get_field() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 14541ca2bf3766e659a22c5ea9ed3dc2d5f11fa5 Auto-Submitted: auto-generated Date: Wed, 11 Nov 2026 19:46:00 +0000 Message-Id: <6af4c5f8.8984.7feffe3@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=14541ca2bf3766e659a22c5ea9ed3dc2d5f11fa5 commit 14541ca2bf3766e659a22c5ea9ed3dc2d5f11fa5 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-11 19:45:14 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-11 19:45:14 +0000 tftpd: Fix off-by-one in get_field() Due to a logic error, get_field() would behave as if the passed-in size was one greater than it actually is. Fix it so it always fails if no terminating NUL is found within the buffer, instead of succeeding if the first byte past the end is a NUL. MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D61032 --- libexec/tftpd/tftp-utils.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libexec/tftpd/tftp-utils.c b/libexec/tftpd/tftp-utils.c index 8ce7c09c9992..9cda798462e6 100644 --- a/libexec/tftpd/tftp-utils.c +++ b/libexec/tftpd/tftp-utils.c @@ -109,16 +109,15 @@ get_field(int peer, char *buffer, size_t size) { char *cp = buffer; - while (cp < buffer + size) { - if (*cp == '\0') break; + while (size > 0) { + if (*cp == '\0') + return (cp - buffer + 1); cp++; + size--; } - if (*cp != '\0') { - tftp_log(LOG_ERR, "Bad option - no trailing \\0 found"); - send_error(peer, EBADOP); - exit(1); - } - return (cp - buffer + 1); + tftp_log(LOG_ERR, "Bad option - no trailing \\0 found"); + send_error(peer, EBADOP); + exit(1); } /*