From 82bb4331f5b639905cf71f82af21acc51776e1e5 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Thu, 2 Apr 2026 13:11:25 +0000 Subject: [PATCH] state: fix routesChanged mutating input Hostinfo routesChanged aliases newHI.RoutableIPs into a local variable then sorts it in place, which mutates the caller's Hostinfo data. The Hostinfo is subsequently stored on the node, so the mutation propagates but the input contract is violated. Clone the slice before sorting to avoid mutating the input. --- hscontrol/state/state.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hscontrol/state/state.go b/hscontrol/state/state.go index 6ba80b21..5091dda9 100644 --- a/hscontrol/state/state.go +++ b/hscontrol/state/state.go @@ -2560,7 +2560,7 @@ func routesChanged(oldNode types.NodeView, newHI *tailcfg.Hostinfo) bool { oldRoutes = oldNode.AsStruct().Hostinfo.RoutableIPs } - newRoutes := newHI.RoutableIPs + newRoutes := slices.Clone(newHI.RoutableIPs) if newRoutes == nil { newRoutes = []netip.Prefix{} }