Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close file on invalid range #15166

Merged
merged 5 commits into from
Apr 3, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/lfs/content_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.Error("Whilst trying to read LFS OID[%s]: Unable to close Error: %v", meta.Oid, err)
log.Error("Whilst trying to read LFS OID[%s]: Unable to close: %v", meta.Oid, err)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not very familiar with this code, but shouldn't we close in the other error-cases too? (Unable to seek)

Yup it's gonna need that too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of log messages in that function look like this - so if you want to clean this up - you need to clean them all up.

}
return nil, ErrRangeNotSatisfiable{
FromByte: fromByte,
}
Expand Down