Skip to content

WIP: Attempt to add test for malformed skyfile

Jan Vornberger requested to merge jav_/Sia:malformed-skyfile into master

WIP: This test does not yet work - looking for feedback.

I stumbled across a bug regarding skylinks: If you take a random sector that is available on the Sia network and create a skylink that points to it, then accessing that skylink will sometimes crash siad. For example with a panic: runtime error: slice bounds out of range in modules/renter/skyfile.go:521 because some bogus ll.fanoutSize is read and used to access baseSector:

fanoutBytes := baseSector[offset : offset+ll.fanoutSize]

The following skylink is such an example and siad crashes when I try to access it with:

wget -U "Sia-Agent" "localhost:9980/skynet/skylink/_B07DUi-d5Lrzrp5RcsJNB656oUW7-OHSbIk_LfBMqvQvw"

I tried to create a test to more generally find problems with malformed skyfiles. I cobbled together some code from various tests with the following strategy: Use one renter to manually upload a sector of random data to a host, get the sector root, build a skylink from that and then use a second renter to access that skylink. So far I was not able to make it work - the test reports unable to fetch base sector of skylink; unable to fetch sector root from the network; workers were unable to recover the data by sector root - all workers failed.

Perhaps this is not a viable testing strategy and I am misunderstanding how various parts play together. I would appreciate feedback from someone who is more familiar with the code base and the tests. Thanks in advance!

Merge request reports