1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-04 17:47:19 +00:00

Read expected buffer size (#17409) (#17430)

Backport of #17409

* Read expected buffer size.

* Changed name.
This commit is contained in:
KN4CK3R
2021-10-25 18:46:56 +02:00
committed by GitHub
parent 06da10b9a1
commit 5159055278
11 changed files with 51 additions and 29 deletions

View File

@ -12,6 +12,7 @@ import (
"io/ioutil"
"code.gitea.io/gitea/modules/typesniffer"
"code.gitea.io/gitea/modules/util"
)
// This file contains common functions between the gogit and !gogit variants for git Blobs
@ -29,7 +30,7 @@ func (b *Blob) GetBlobContent() (string, error) {
}
defer dataRc.Close()
buf := make([]byte, 1024)
n, _ := dataRc.Read(buf)
n, _ := util.ReadAtMost(dataRc, buf)
buf = buf[:n]
return string(buf), nil
}