From 5ec7734d88247adad25415b8f6bae781e7a6a7b8 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Fri, 8 Jul 2016 08:19:45 +0530 Subject: [PATCH] FS: Check offset is within object size in GetObject() (#2123) Fixes #2118 --- fs-v1.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs-v1.go b/fs-v1.go index 402e4c97c..13f2b8a0d 100644 --- a/fs-v1.go +++ b/fs-v1.go @@ -221,6 +221,16 @@ func (fs fsObjects) GetObject(bucket, object string, offset int64, length int64, if offset < 0 || length < 0 { 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 bufSize := int64(readSizeV1) if length > 0 && bufSize > length {