Date: Mon, 09 Mar 2026 13:27:16 +0000 From: Ed Maste <emaste@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Mark Johnston <markj@FreeBSD.org> Subject: git: 969c436a6c91 - stable/14 - bhyve: Fix truncate_iov() Message-ID: <69aecab4.2758a.5a1ad16f@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=969c436a6c918be0f000bd317f06985a7dd92809 commit 969c436a6c918be0f000bd317f06985a7dd92809 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-02-24 15:14:39 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2026-03-05 23:57:56 +0000 bhyve: Fix truncate_iov() The implementation was simply wrong. It would always just return the first entry in the iovec, even if the requested length is larger than that first entry. Note, this function will be removed soon, see D53468. Reported by: Vinod p n <vinod272@gmail.com> Reviewed by: des, emaste, Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D55438 (cherry picked from commit d7d4da91de201841c57a6b8f89b450754b9b8696) (cherry picked from commit 119bdea35792006cd0cce3c864d5007f092a10c1) --- usr.sbin/bhyve/iov.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/usr.sbin/bhyve/iov.c b/usr.sbin/bhyve/iov.c index d01c7a5601f4..7b8564c302af 100644 --- a/usr.sbin/bhyve/iov.c +++ b/usr.sbin/bhyve/iov.c @@ -82,19 +82,14 @@ count_iov(const struct iovec *iov, int niov) void truncate_iov(struct iovec *iov, int *niov, size_t length) { - size_t done = 0; int i; - for (i = 0; i < *niov; i++) { - size_t toseek = MIN(length - done, iov[i].iov_len); - done += toseek; - - if (toseek <= iov[i].iov_len) { - iov[i].iov_len = toseek; - *niov = i + 1; - return; - } + for (i = 0; i < *niov && length > 0; i++) { + if (length < iov[i].iov_len) + iov[i].iov_len = length; + length -= iov[i].iov_len; } + *niov = i; } ssize_thome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69aecab4.2758a.5a1ad16f>
