From 22e34cb12e0e9f95335cc2bd2898a66b4fe4a5ce Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Fri, 26 Mar 2021 07:37:04 +0000 Subject: [PATCH 1/2] Close file on invalid range. --- modules/lfs/content_store.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go index 788ef5b9a6950..aa79c34621e66 100644 --- a/modules/lfs/content_store.go +++ b/modules/lfs/content_store.go @@ -53,6 +53,10 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC } if fromByte > 0 { if fromByte >= meta.Size { + err = f.Close() + if err != nil { + log.Error("Whilst trying to read LFS OID[%s]: Unable to close Error: %v", meta.Oid, err) + } return nil, ErrRangeNotSatisfiable{ FromByte: fromByte, } From c7fc2355574aa747f27511b82ff9328816579650 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Fri, 26 Mar 2021 10:33:15 +0000 Subject: [PATCH 2/2] Close on seek error Signed-off-by: Andrew Thornton --- modules/lfs/content_store.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go index aa79c34621e66..9473cc35c2bff 100644 --- a/modules/lfs/content_store.go +++ b/modules/lfs/content_store.go @@ -64,6 +64,10 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC _, err = f.Seek(fromByte, io.SeekStart) if err != nil { log.Error("Whilst trying to read LFS OID[%s]: Unable to seek to %d Error: %v", meta.Oid, fromByte, err) + errClose := f.Close() + if errClose != nil { + log.Error("Whilst trying to read LFS OID[%s]: Unable to close Error: %v", meta.Oid, errClose) + } } } return f, err