fix panic in tun handler

This commit is contained in:
ginuerzh
2023-10-08 22:04:36 +08:00
parent 6a36ebcc9f
commit 61f1f05339
2 changed files with 12 additions and 0 deletions

View File

@ -49,6 +49,9 @@ func (h *tunHandler) transportServer(ctx context.Context, tun io.ReadWriter, con
if err != nil {
return ErrTun
}
if n == 0 {
return nil
}
var src, dst net.IP
if waterutil.IsIPv4((*b)[:n]) {
@ -110,6 +113,9 @@ func (h *tunHandler) transportServer(ctx context.Context, tun io.ReadWriter, con
if err != nil {
return err
}
if n == 0 {
return nil
}
if n > keepAliveHeaderLength && bytes.Equal((*b)[:4], magicHeader) {
var peerIPs []net.IP
data := (*b)[keepAliveHeaderLength:n]