Weird behaviour of DagReader.Seek() when using with SEEK_END #2567
Labels
help wanted
Seeking public contribution on this issue
kind/bug
A bug in existing code (including security flaws)
Projects
Seek(0, SEEK_END)
might sometimes return either the size of the stream in bytes (correct) or0 (and
io.EOF
) on other occasions. I put together a minimal working example here:https://gist.github.com/sahib/4363c36dc2352d1fba7634fd46eb7978
Steps to reproduce:
Another oddity:
ipfs
seems to use a positive offset for going back fromSEEK_END
, while other implementation usually use negative offsets to go back from the end and positive to extend above the file limits. Example:I failed to find a good reference that suggests that behaviour,
but the go docs say this about
SEEK_END
:...where
relative to
(hopefully) should mean the same direction for all whences.This should be easy to change, since (after a quick look)
ipfs
only ever usesSeek(0, SEEK_END)
.The text was updated successfully, but these errors were encountered: