mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-11 03:27:20 +02:00
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.
This commit is contained in:
committed by
Kristoffer Dalby
parent
2a2d5c869a
commit
82bb4331f5
@@ -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{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user