prober: fix nil pointer access in tcp-in-tcp probes

If unable to accept a connection from the bandwidth probe listener,
return from the goroutine immediately since the accepted connection
will be nil.

Updates tailscale/corp#25958

Signed-off-by: Percy Wegmann <percy@tailscale.com>
This commit is contained in:
Percy Wegmann 2025-01-18 20:41:36 -06:00 committed by Percy Wegmann
parent 7f3c1932b5
commit 2729942638

View File

@ -1048,6 +1048,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
readConn, err := l.Accept()
if err != nil {
readFinishedC <- err
return
}
defer readConn.Close()
deadline, ok := ctx.Deadline()
@ -1055,6 +1056,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
// Don't try reading past our context's deadline.
if err := readConn.SetReadDeadline(deadline); err != nil {
readFinishedC <- fmt.Errorf("unable to set read deadline: %w", err)
return
}
}
n, err := io.CopyN(io.Discard, readConn, size)