aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-10-24 23:12:43 +0200
committerGitHub <noreply@github.com>2021-10-24 22:12:43 +0100
commitf99d50fc9f8baf406f32a491b214f8a13617d086 (patch)
treeb3cd8a1304e522f111690e9f68130e663012bb16 /modules/repofiles
parent932780c2bbae09f052e2fcd1a0701966483496e8 (diff)
downloadgitea-f99d50fc9f8baf406f32a491b214f8a13617d086.tar.gz
gitea-f99d50fc9f8baf406f32a491b214f8a13617d086.zip
Read expected buffer size (#17409)
* Read expected buffer size. * Changed name.
Diffstat (limited to 'modules/repofiles')
-rw-r--r--modules/repofiles/update.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go
index dc2893cb1c..d25accff18 100644
--- a/modules/repofiles/update.go
+++ b/modules/repofiles/update.go
@@ -19,6 +19,7 @@ import (
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
+ "code.gitea.io/gitea/modules/util"
stdcharset "golang.org/x/net/html/charset"
"golang.org/x/text/transform"
@@ -61,7 +62,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string
}
defer reader.Close()
buf := make([]byte, 1024)
- n, err := reader.Read(buf)
+ n, err := util.ReadAtMost(reader, buf)
if err != nil {
// return default
return "UTF-8", false
@@ -84,7 +85,7 @@ func detectEncodingAndBOM(entry *git.TreeEntry, repo *models.Repository) (string
}
defer dataRc.Close()
buf = make([]byte, 1024)
- n, err = dataRc.Read(buf)
+ n, err = util.ReadAtMost(dataRc, buf)
if err != nil {
// return default
return "UTF-8", false