From nobody Mon Nov 16 15:17:45 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 4jSs1P6BR8z70r70 for ; Mon, 16 Nov 2026 15:17:45 +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 4jSs1P0mycz4R47 for ; Mon, 16 Nov 2026 15:17:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794842265; 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=XCSPD+52hWiullrDURCaDv+PhAFqp+9sPduYGG96Wic=; b=aWyZSXVKloBT+LJu1Bi5ycnlFv+HkyvK8m7vtlGGTNoXUQ3ZFCxTY9NstObkxy2/dfNYV4 tc4ZuWAJwm5HtKqWh3eVclyA6tyO83RyRm6otWeFOmoJbizTSYUZjd6Y6Dw/UPE/cE55FZ Xdz5xQM9h1fDgG+xAPDkbeC4TBRIUOTJPTVVgSRJvUNpjjOBAxjCjB5nUcmGfLqZzzhTUR LFTqBpUJ9S4dAQhGpMtC2UZPSpY8YBr9wu/PJHNEwtn6XoJled9gQ/XjWAcgy7/JSsmx2V JtzeltWYpc0M3v7vRQeYFyLCZ7yESklWSms2YxrnDutPJUit8JkvLcagQizogg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794842265; b=byLn0BKNabLYNkBYTtWEW78F1un9XOeqY0rsjlpKrN0dkzXO4MOmNbyblVQqRnT3B20PXc Udu0XCTq/ntjOsFrLY7jF2we1+N4bH/2octOVLyAKvTYpPkYVoy8seNd3oEG17WR2q6h95 NwQqZCllNKnjQX0s2oRjraiLXCGvHFb7WNR9WGcoBiGnMQeeyCYWBQCRJgBOrHMbZI77mV nTKg4o0J4BFFIgv5bZFd9PNkXXydoqybQ1NVa/QouwJr3fOJFqfqh1LRZJUh+fHPUJ4sTG iwz7zc4GSKISepABMIpnhJsxYhyNMUbejPnDJLo2NDrXUIreuub95KoWCDVIKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794842265; 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=XCSPD+52hWiullrDURCaDv+PhAFqp+9sPduYGG96Wic=; b=SDY8rQscQWgkAVgztec9aTKpNDr0ZMvPyXLBpf0L+VBVY6NT+BmVU141k9oiaMmdhVb+UL 6F6bwfPKSab+TzmkD2/tV+pCqAlL4T7GtwsUPTWxgZXfGvbHyRt7OmJ73+Yecu/i/zafnD Pxdw+6HazKRNCOagZzdseSjdllEFW10D2Yvu1yL74FRIFau/5LxeWzWfQXA8TtVrcqG2PK xAE9SoMxjjFgENSefIQvNlArmYkHjjmIsIybUZFMMjNWC+ukrB+jDZymDK6dyckce0ilkz NydYXwQ8H3V0ZehDuXWHFep77ywzcW2yakf0vJPI9woZvpVOu4V/BwHpE4GJHw== 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 4jSs1P0MDBz1037 for ; Mon, 16 Nov 2026 15:17:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4412 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 16 Nov 2026 15:17:45 +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: 9a44e1769b90 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 9a44e1769b909328fb064bc16a70e1746f26fac2 Auto-Submitted: auto-generated Date: Mon, 16 Nov 2026 15:17:45 +0000 Message-Id: <6afb1e99.4412.30b16c11@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=9a44e1769b909328fb064bc16a70e1746f26fac2 commit 9a44e1769b909328fb064bc16a70e1746f26fac2 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-11 19:45:24 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-16 14:52:03 +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 7a261ac3d7c3..609ed98a7545 100644 --- a/libexec/tftpd/tftp-options.c +++ b/libexec/tftpd/tftp-options.c @@ -365,13 +365,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); @@ -392,7 +391,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; } @@ -410,24 +409,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; @@ -459,8 +460,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 *);