1
0
mirror of https://gitcode.com/gitea/gitea.git synced 2025-07-09 06:40:05 +08:00

Discard unread data of git cat-file ()

Fixes 
Related 

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
10 changed files with 66 additions and 80 deletions

@ -121,8 +121,7 @@ func (repo *Repository) getCommitFromBatchReader(rd *bufio.Reader, id ObjectID)
return commit, nil
default:
log.Debug("Unknown typ: %s", typ)
_, err = rd.Discard(int(size) + 1)
if err != nil {
if err := DiscardFull(rd, size+1); err != nil {
return nil, err
}
return nil, ErrNotExist{