fix core_test.go and a race in setting/using mtu

This commit is contained in:
Arceliar 2021-06-13 13:40:20 -05:00
parent cb81be94ec
commit b34c3230f8
3 changed files with 33 additions and 13 deletions

View file

@ -243,12 +243,15 @@ func (k *keyStore) readPC(p []byte) (int, error) {
if len(bs) < 40 {
continue
}
if len(bs) > int(k.mtu) {
k.mutex.Lock()
mtu := int(k.mtu)
k.mutex.Unlock()
if len(bs) > mtu {
// Using bs would make it leak off the stack, so copy to buf
buf := make([]byte, 40)
copy(buf, bs)
ptb := &icmp.PacketTooBig{
MTU: int(k.mtu),
MTU: mtu,
Data: buf[:40],
}
if packet, err := CreateICMPv6(buf[8:24], buf[24:40], ipv6.ICMPTypePacketTooBig, 0, ptb); err == nil {