Discard unread data of git cat-file (#29297)

Fixes #29101
Related #29298

Discard all read data to prevent misinterpreting existing data. Some
discard calls were missing in error cases.

---------

Co-authored-by: yp05327 <576951401@qq.com>
This commit is contained in:
KN4CK3R 2024-02-22 04:48:19 +01:00 committed by GitHub
parent c236e64aca
commit d6811baf88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 66 additions and 80 deletions

View file

@ -58,6 +58,9 @@ func (repo *Repository) getTree(id ObjectID) (*Tree, error) {
tree.entriesParsed = true
return tree, nil
default:
if err := DiscardFull(rd, size+1); err != nil {
return nil, err
}
return nil, ErrNotExist{
ID: id.String(),
}