git: f4e7cb535b9c - main - gvirstor: in virstor_ctl_remove() the copy length of the second bcopy might be wrong.

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 23 Jul 2025 06:22:12 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=f4e7cb535b9cb1ddd608b382f29d8123931d5212

commit f4e7cb535b9cb1ddd608b382f29d8123931d5212
Author:     Wuyang Chung <wy-chung@outlook.com>
AuthorDate: 2025-07-12 16:09:36 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-07-23 06:03:48 +0000

    gvirstor: in virstor_ctl_remove() the copy length of the second bcopy might be wrong.
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1763
---
 sys/geom/virstor/g_virstor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c
index b8cf32875660..73bd9f73055a 100644
--- a/sys/geom/virstor/g_virstor.c
+++ b/sys/geom/virstor/g_virstor.c
@@ -589,7 +589,7 @@ virstor_ctl_remove(struct gctl_req *req, struct g_class *cp)
 		    M_GVIRSTOR, M_WAITOK | M_ZERO);
 		bcopy(sc->components, newcomp, found * sizeof(*sc->components));
 		bcopy(&sc->components[found + 1], newcomp + found,
-		    found * sizeof(*sc->components));
+		    (sc->n_components - (found + 1)) * sizeof(*sc->components));
 		if ((sc->components[j].flags & VIRSTOR_PROVIDER_ALLOCATED) != 0) {
 			LOG_MSG(LVL_ERROR, "Allocated provider %s cannot be "
 			    "removed from %s",