aboutsummaryrefslogtreecommitdiffstats
path: root/vitest.config.js
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2024-02-21 19:54:17 +0100
committerGitHub <noreply@github.com>2024-02-21 19:54:17 +0100
commitf74c869221624092999097af38b6f7fae4701420 (patch)
tree8f47cd079567cea05b940c2b761bdbe6a8064722 /vitest.config.js
parente6e50696b83164805bec83a1b20c95a85a4dd7e5 (diff)
downloadgitea-f74c869221624092999097af38b6f7fae4701420.tar.gz
gitea-f74c869221624092999097af38b6f7fae4701420.zip
Prevent double use of `git cat-file` session. (#29298)
Fixes the reason why #29101 is hard to replicate. Related #29297 Create a repo with a file with minimum size 4097 bytes (I use 10000) and execute the following code: ```go gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, <repo>) assert.NoError(t, err) commit, err := gitRepo.GetCommit(<sha>) assert.NoError(t, err) entry, err := commit.GetTreeEntryByPath(<file>) assert.NoError(t, err) b := entry.Blob() // Create a reader r, err := b.DataAsync() assert.NoError(t, err) defer r.Close() // Create a second reader r2, err := b.DataAsync() assert.NoError(t, err) // Should be no error but is ErrNotExist defer r2.Close() ``` The problem is the check in `CatFileBatch`: https://github.com/go-gitea/gitea/blob/79217ea63c1f77de7ca79813ae45950724e63d02/modules/git/repo_base_nogogit.go#L81-L87 `Buffered() > 0` is used to check if there is a "operation" in progress at the moment. This is a problem because we can't control the internal buffer in the `bufio.Reader`. The code above demonstrates a sequence which initiates an operation for which the code thinks there is no active processing. The second call to `DataAsync()` therefore reuses the existing instances instead of creating a new batch reader.
Diffstat (limited to 'vitest.config.js')
0 files changed, 0 insertions, 0 deletions