FS: Check offset is within object size in GetObject() (#2123)

Fixes #2118
This commit is contained in:
Bala FA 2016-07-08 08:19:45 +05:30 committed by Harshavardhana
parent 2c837128ef
commit 5ec7734d88
1 changed files with 10 additions and 0 deletions

View File

@ -221,6 +221,16 @@ func (fs fsObjects) GetObject(bucket, object string, offset int64, length int64,
if offset < 0 || length < 0 { if offset < 0 || length < 0 {
return toObjectErr(errUnexpected, bucket, object) return toObjectErr(errUnexpected, bucket, object)
} }
fi, err := fs.storage.StatFile(bucket, object)
if err != nil {
return toObjectErr(err, bucket, object)
}
if offset > fi.Size {
return InvalidRange{}
}
var totalLeft = length var totalLeft = length
bufSize := int64(readSizeV1) bufSize := int64(readSizeV1)
if length > 0 && bufSize > length { if length > 0 && bufSize > length {