From nobody Mon Nov 16 15:17:56 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 4jSs1d2QQqz70rTZ for ; Mon, 16 Nov 2026 15:17:57 +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 4jSs1d190Nz4RSF for ; Mon, 16 Nov 2026 15:17:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794842277; 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=IpT7m8jiR9VBNlotLWyfnde5o4l1pxJ+yPKi1PAs2dY=; b=dnFSbofcPxiByDtT7vgR52fqXZXrJ9mXw1i7KCfnfuTwpWtOWUL210dSbiRSxjhtVBGUoX jRSu27y1bJxdRGz+nxNM2tXE2Mf1NnU2se1sZiuHiMNw62uydCc6y8ldqYJfzHNTIcG1kA y94EKp87mvZAw0lG1ER1QeGbojFslASW/AFkml3aTss1D/B9h233pZXrngbRjYTsqFCnuD SlUl8yIZtt6MptPNWeFhFBlyotTWHo4CAZA8PM/nLvBAZgoainYSax8gHMe2FNHPsam+Fj T8G61rX7BZf9R+HODBWg4PfW6Hfsb6OJgY/Z82QprkryAJyBCpK+CEvY87AoVQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794842277; b=cDzEv5lPQJv1m59a7nVVMZT+BolmT7WgM4uq9HjWVGef1SNwom8sltC5W+UDtb0QrAOQ8N 5pGKAofjDbAMy6dr3cKLto5UodVEUU34c+tSRKvXjeWPszQuA6Gkj7UxgSpQbvBrSGtAgA a84d+tRHQIYOUpCHNQ0N+lNheiumyEnMOwX5nM8UYtmqth4j9iIZuEW5oSM4TM7rNSH06v Up9EwAX68U4zLfJ4RSrNU29p8k1su4FGY33EfeIjA6uWB5AL+n71tgG0KacZbZ3VW0lXr2 qOdnU7YxO8M94yM1otikS+VAH6tBggGd5WSdNylGxb/M0q/UoE/XVO6HRpoFTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794842277; 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=IpT7m8jiR9VBNlotLWyfnde5o4l1pxJ+yPKi1PAs2dY=; b=GsEozzqh+332AbGwWtlqTqPMdUP6aLDwwZtVW97jIB6SqWnbeJ3IQevpX7GB1kbCzFX6u6 kPO54hRrQGvwggIZgx/XpwKnd4ltCx4Q6M9l+L6lJM0e0JGO1Fj2bYFQiYJ1f6782XnVch hRcjAGL10dCOwjgd/l+hboRnK+Hi9FzHlyrUQT8Cu0IPfBWHCBlKKYJDp14LPyvhAZ8EMz rzhlkamOvbdvMqUrUNrLP4sGP16h/DxoCCTC3V4jNLoUSEetlSmf5ekEdkhgNYbnhGfq72 uDwOXmoM39Heab/9oVsLRV2iEgq/9qmOr0ZrzZs/XPxItToJ410/XpqfscBWug== 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 4jSs1c30g2z103B for ; Mon, 16 Nov 2026 15:17:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 439b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 15:17:56 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: d93901491d49 - stable/14 - tftpd: Keep proper track of option length 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/stable/14 X-Git-Reftype: branch X-Git-Commit: d93901491d49258cd1a234a40f2816e8ca945329 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 15:17:56 +0000 Message-Id: <6afb1ea4.439b.34fbb8fc@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=d93901491d49258cd1a234a40f2816e8ca945329 commit d93901491d49258cd1a234a40f2816e8ca945329 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-11 19:45:24 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-16 14:52:04 +0000 tftpd: Keep proper track of option length When parsing options, keep track of the length of the unparsed portion and pass that to get_field() instead of the length of the entire header. While here, switch both make_options() and parse_options() to using size_t for sizes and lengths. MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D61048 (cherry picked from commit 35cd70490f4b7ec1921db980ae3992192e4cbfbb) --- libexec/tftpd/tftp-options.c | 29 ++++++++++++++--------------- libexec/tftpd/tftp-options.h | 6 +++--- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/libexec/tftpd/tftp-options.c b/libexec/tftpd/tftp-options.c index ee413603fbfb..da4a020f5e1a 100644 --- a/libexec/tftpd/tftp-options.c +++ b/libexec/tftpd/tftp-options.c @@ -366,13 +366,12 @@ option_windowsize(int peer) /* * Append the available options to the header */ -uint16_t -make_options(int peer __unused, char *buffer, uint16_t size) { - int i; +size_t +make_options(int peer __unused, char *buffer, size_t size) +{ char *value; const char *option; - uint16_t length; - uint16_t returnsize = 0; + size_t i, length, returnsize = 0; if (!options_rfc_enabled) return (0); @@ -393,7 +392,7 @@ make_options(int peer __unused, char *buffer, uint16_t size) { tftp_log(LOG_ERR, "Running out of option space for " "option '%s' with value '%s': " - "needed %d bytes, got %d bytes", + "needed %zu bytes, got %zu bytes", option, value, size, length); continue; } @@ -411,24 +410,26 @@ make_options(int peer __unused, char *buffer, uint16_t size) { * Parse the received options in the header */ int -parse_options(int peer, char *buffer, uint16_t size) +parse_options(int peer, char *buffer, size_t size) { + char *c, *cp, *end, *option, *value; + size_t len; int i, options_failed; - char *c, *cp, *option, *value; if (!options_rfc_enabled) return (0); /* Parse the options */ cp = buffer; + end = buffer + size; options_failed = 0; - while (size > 0) { + while (cp < end) { option = cp; - i = get_field(peer, cp, size); - cp += i; + len = get_field(peer, cp, end - cp); + cp += len; value = cp; - i = get_field(peer, cp, size); - cp += i; + len = get_field(peer, cp, end - cp); + cp += len; /* We are at the end */ if (*option == '\0') break; @@ -460,8 +461,6 @@ parse_options(int peer, char *buffer, uint16_t size) if (options[i].o_type == NULL) tftp_log(LOG_WARNING, "Unknown option: '%s'", option); - - size -= strlen(option) + strlen(value) + 2; } return (options_failed); diff --git a/libexec/tftpd/tftp-options.h b/libexec/tftpd/tftp-options.h index f1b0a5cfaf32..26f0191b1542 100644 --- a/libexec/tftpd/tftp-options.h +++ b/libexec/tftpd/tftp-options.h @@ -29,9 +29,9 @@ * Options */ -void init_options(void); -uint16_t make_options(int peer, char *buffer, uint16_t size); -int parse_options(int peer, char *buffer, uint16_t size); +void init_options(void); +size_t make_options(int peer, char *buffer, size_t size); +int parse_options(int peer, char *buffer, size_t size); /* Call back functions */ int option_tsize(int peer, struct tftphdr *, int, struct stat *);