Fix copy() in SVCBIPv4Hint and SVCBIPv6Hint (#1256)
* Fix copy() in SVCBIPv4Hint and SVCBIPv6Hint The problem with the current implementation is that it is not a real deep copy, it points to the same base arrays behind the slices. This was causing some issues in real-life application. * Address review comments
This commit is contained in:
parent
88913150f0
commit
c99ea652e3
14
svcb.go
14
svcb.go
|
@ -511,8 +511,13 @@ func (s *SVCBIPv4Hint) parse(b string) error {
|
|||
}
|
||||
|
||||
func (s *SVCBIPv4Hint) copy() SVCBKeyValue {
|
||||
hint := make([]net.IP, len(s.Hint))
|
||||
for i, ip := range s.Hint {
|
||||
hint[i] = copyIP(ip)
|
||||
}
|
||||
|
||||
return &SVCBIPv4Hint{
|
||||
append([]net.IP(nil), s.Hint...),
|
||||
Hint: hint,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -629,8 +634,13 @@ func (s *SVCBIPv6Hint) parse(b string) error {
|
|||
}
|
||||
|
||||
func (s *SVCBIPv6Hint) copy() SVCBKeyValue {
|
||||
hint := make([]net.IP, len(s.Hint))
|
||||
for i, ip := range s.Hint {
|
||||
hint[i] = copyIP(ip)
|
||||
}
|
||||
|
||||
return &SVCBIPv6Hint{
|
||||
append([]net.IP(nil), s.Hint...),
|
||||
Hint: hint,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue