File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import (
2828 "os"
2929 "os/signal"
3030 "path/filepath"
31+ "slices"
3132 "syscall"
3233 "time"
3334
@@ -97,7 +98,8 @@ func logic() error {
9798 if err != nil {
9899 return err
99100 }
100- hwaddr := iface .HardwareAddr
101+ // Clone the hardware address as the backing array does not remain valid.
102+ hwaddr := slices .Clone (iface .HardwareAddr )
101103 // The interface may not have been configured by netconfigd yet and might
102104 // still use the old hardware address. We overwrite it with the address that
103105 // netconfigd is going to use to fix this issue without additional
Original file line number Diff line number Diff line change @@ -103,7 +103,8 @@ func (c *Client) ObtainOrRenew() bool {
103103 return
104104 }
105105 if c .hardwareAddr == nil && c .HWAddr != nil {
106- c .hardwareAddr = c .HWAddr
106+ // Clone the hardware address as the backing array does not remain valid.
107+ c .hardwareAddr = slices .Clone (c .HWAddr )
107108 }
108109 if c .hardwareAddr == nil {
109110 // Defensive slices.Clone because I noticed c.hardwareAddr
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
1919 "fmt"
2020 "log"
2121 "net"
22+ "slices"
2223 "strconv"
2324 "time"
2425
@@ -115,9 +116,10 @@ func NewClient(cfg ClientConfig) (*Client, error) {
115116 }
116117 }
117118
118- hardwareAddr := iface .HardwareAddr
119+ // Clone the hardware address as the backing array does not remain valid.
120+ hardwareAddr := slices .Clone (iface .HardwareAddr )
119121 if cfg .HardwareAddr != nil {
120- hardwareAddr = cfg .HardwareAddr
122+ hardwareAddr = slices . Clone ( cfg .HardwareAddr )
121123 }
122124
123125 var duid * dhcpv6.Duid
You can’t perform that action at this time.
0 commit comments