git: 9d2cdb3fd574 - main - routing: Fix buffer size in merge_nhgrps()

From: Pouria Mousavizadeh Tehrani <pouria_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 22:53:08 UTC
The branch main has been updated by pouria:

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

commit 9d2cdb3fd5741685622b0b9c0e17e22583c9ceff
Author:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
AuthorDate: 2026-11-11 22:50:18 +0000
Commit:     Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
CommitDate: 2026-11-11 22:50:18 +0000

    routing: Fix buffer size in merge_nhgrps()
    
    merge_nhgrps() sized its temporary nexthop array as twice
    the existing group instead of the sum of both groups.
    
    Fixes:  dd945c6ba4ff ("routing: Implement merge of nhgrp in new multipath route")
---
 sys/net/route/nhgrp_ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/net/route/nhgrp_ctl.c b/sys/net/route/nhgrp_ctl.c
index 4d0694c330ba..93c468e785c8 100644
--- a/sys/net/route/nhgrp_ctl.c
+++ b/sys/net/route/nhgrp_ctl.c
@@ -710,7 +710,7 @@ merge_nhgrps(struct nh_control *ctl, const struct nhgrp_object *gr_orig,
 
 	*perror = 0;
 
-	sz = (orig_priv->nhg_nh_count + orig_priv->nhg_nh_count) *
+	sz = (orig_priv->nhg_nh_count + add_priv->nhg_nh_count) *
 		sizeof(struct weightened_nhop);
 	/* optimize for <= 4 paths, each path=16 bytes */
 	if (sz <= sizeof(storage))