Accessing /skynet/skylink/<skylink> crashes siad for certain skylinks
BUG REPORT
Playing around with skynet, I stumbled onto a skylink that crashes siad
when trying to fetch it.
Stack Trace or error message
panic: runtime error: slice bounds out of range
goroutine 2821 [running]:
gitlab.com/NebulousLabs/Sia/modules/renter.(*Renter).DownloadSkylink(0xc0001ee2c0, 0x9277be480d3b1dfc, 0x3409cb4579baceeb, 0x87e3ef1685eab91e, 0xab32c1b7fc24b249, 0xbfd0, 0xc002f0e200, 0x1, 0x2, 0xd19a80, ...)
/build/Sia/modules/renter/skyfile.go:521 +0xb13
gitlab.com/NebulousLabs/Sia/node/api.(*API).skynetSkylinkHandlerGET(0xc0004ec000, 0xf35320, 0xc00267a0e0, 0xc001d78000, 0xc002f0e1c0, 0x1, 0x1)
/build/Sia/node/api/renter.go:1853 +0x502
github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc0001d2de0, 0xf35320, 0xc00267a0e0, 0xc001d78000)
/build/go/pkg/mod/github.com/julienschmidt/httprouter@v1.3.0/router.go:387 +0xa3c
gitlab.com/NebulousLabs/Sia/node/api.RequireUserAgent.func1(0xf35320, 0xc00267a0e0, 0xc001d78000)
/build/Sia/node/api/routes.go:238 +0x11f
net/http.HandlerFunc.ServeHTTP(0xc002956540, 0xf35320, 0xc00267a0e0, 0xc001d78000)
/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-go-1.12.16/share/go/src/net/http/server.go:1995 +0x44
gitlab.com/NebulousLabs/Sia/node/api.cleanCloseHandler.func1.1(0xc000382480, 0xf26900, 0xc002956540, 0xf35320, 0xc00267a0e0, 0xc001d78000)
/build/Sia/node/api/routes.go:209 +0x79
created by gitlab.com/NebulousLabs/Sia/node/api.cleanCloseHandler.func1
/build/Sia/node/api/routes.go:207 +0xa0
Expected Behavior
siad
should deliver the file or report some kind of error, but keep running.
Observed Behavior
siad
crashes.
How to reproduce it (as minimally and precisely as possible)
siad
needs to be configured as a portal or happen to have the relevant contract anyway for some reason. Then:
curl -A "Sia-Agent" "localhost:9980/skynet/skylink/_B07DUi-d5Lrzrp5RcsJNB656oUW7-OHSbIk_LfBMqvQvw"
Environment
- Sia version: Sia Daemon v1.4.4, Git Revision 7a752c57, Running with debugging enabled
- OS: Linux 4.19.103, NixOS, x86_64
Notes
Related: I attempted in !4184 (closed) to create an automatic test for this bug.