Closed wuxingzhong closed 1 year ago
There's a check for 0 mx above, and it's a uint. For this to happen, surely you have something returning a huge mx that overflows when multiplied by time.Second. Have I missed something?
There's a check for 0 mx above, and it's a uint. For this to happen, surely you have something returning a huge mx that overflows when multiplied by time.Second. Have I missed something?
yes, a huge mx
that overflows when change uint to int64 On 64-bit systems.
func TestUint(t *testing.T) {
mx := uint(9223372036854775808)
fmt.Println("mx:", mx)
fmt.Println("mx2:", int64(mx))
}
output:
mx: 9223372036854775808
mx2: -9223372036854775808
Maybe we should limit the maximum value of mx?
Do you have a misbehaving system on your network to cause this?
Do you have a misbehaving system on your network to cause this?
I'm using vlc to play the files on the dlna server, which may panic once in a while
@wuxingzhong thanks for your contribution!
2023/11/09 11:05:05 INFO : /static/ContentDirectory.xml: 192.168.131.174:52716 GET 200
panic: invalid argument to Int63n
goroutine 1933 [running]: math/rand.(Rand).Int63n(0x140000008c0?, 0x14000046e70?) /opt/homebrew/Cellar/go/1.20.6/libexec/src/math/rand/rand.go:121 +0xe8 math/rand.Int63n(...) /opt/homebrew/Cellar/go/1.20.6/libexec/src/math/rand/rand.go:348 github.com/anacrolix/dms/ssdp.(Server).handle(0x140000008c0, {0x14000706c00, 0x65, 0x5dc}, 0x1400057cfc0?) /go/pkg/mod/github.com/anacrolix/dms@v1.6.0/ssdp/ssdp.go:319 +0x874 created by github.com/anacrolix/dms/ssdp.(*Server).serve /go/pkg/mod/github.com/anacrolix/dms@v1.6.0/ssdp/ssdp.go:129 +0x2c