Add checks for ReadStream offset boundary conditions

Several checks for ReadStream with offset around boundary conditions were
missing. The new checks ensure negative offsets are detected and io.EOF is
returned properly when trying to read past the end of a file. The filesystem
and inmemory driver have been updated accordingly.

An outline of missing checks for List are also part of this commit. Action will
be taken here based on discussion in issue #819.
This commit is contained in:
Stephen J Day 2014-12-05 11:46:41 -08:00
parent 70ab06b864
commit d703a86a64
3 changed files with 51 additions and 0 deletions

View file

@ -83,6 +83,10 @@ func (d *Driver) ReadStream(path string, offset int64) (io.ReadCloser, error) {
d.mutex.RLock()
defer d.mutex.RUnlock()
if offset < 0 {
return nil, storagedriver.InvalidOffsetError{Path: path, Offset: offset}
}
path = d.normalize(path)
found := d.root.find(path)