You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
imohash tries to seek -imo.sampleSize from the end of the reader, but does not verify imo.sampleSize <= f.Size() before doing so, leading to Seek returning an error.
Note that this situation (seemingly?) isn't possible with the default SampleSize and SampleThreshold, since the default SampleThreshold>SampleSize. It's only an issue if you set custom values and SampleSize>SampleThreshold. I don't know the intricacies of the algorithm, so I'm not sure if it's even correct or makes sense to set the values like this.
The text was updated successfully, but these errors were encountered:
This is a good catch and not a particularly obscure edge case. Let me think about the correct way to handle it. Note: I'm traveling, and a PR might take a few days.
See schollz/croc#786 (comment)
The offending code is here:
imohash/imohash.go
Lines 107 to 131 in 3f885db
imohash tries to seek
-imo.sampleSize
from the end of the reader, but does not verifyimo.sampleSize <= f.Size()
before doing so, leading to Seek returning an error.Here's a playground link demonstrating this with
Sum
(panics rather than returning an error): https://go.dev/play/p/wKCwBAo6nsZNote that this situation (seemingly?) isn't possible with the default SampleSize and SampleThreshold, since the default SampleThreshold>SampleSize. It's only an issue if you set custom values and SampleSize>SampleThreshold. I don't know the intricacies of the algorithm, so I'm not sure if it's even correct or makes sense to set the values like this.
The text was updated successfully, but these errors were encountered: