gitea/modules
KN4CK3R f74c869221
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`:

79217ea63c/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.
2024-02-21 19:54:17 +01:00
..
actions Implement some action notifier functions (#29173) 2024-02-18 10:58:46 +00:00
activitypub Upgrade to golangci-lint@v1.55.0 (#27756) 2023-10-24 02:54:59 +00:00
analyze
assetfs
auth Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
avatar
base Use general token signing secret (#29205) 2024-02-18 17:39:04 +00:00
cache Always enable caches (#28527) 2023-12-19 09:29:05 +00:00
charset Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
container
context Remove DataRaceCheck (#29258) 2024-02-19 11:25:58 +00:00
contexttest Improve user experience for outdated comments (#29050) 2024-02-08 01:50:48 +00:00
csv Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
emoji
eventsource Final round of db.DefaultContext refactor (#27587) 2023-10-14 08:37:24 +00:00
generate Refactor JWT secret generating & decoding code (#29172) 2024-02-16 15:18:30 +00:00
git Prevent double use of git cat-file session. (#29298) 2024-02-21 19:54:17 +01:00
gitgraph
gitrepo Simplify how git repositories are opened (#28937) 2024-01-27 21:09:51 +01:00
graceful Suggest to use Type=simple for systemd service (#28717) 2024-01-07 15:18:04 +00:00
hcaptcha
highlight Add option to disable ambiguous unicode characters detection (#28454) 2023-12-17 14:38:54 +00:00
hostmatcher Support allowed hosts for webhook to work with proxy (#27655) 2023-10-18 09:44:36 +00:00
html
httpcache Also match weakly validated ETags (#28957) 2024-01-29 16:18:40 +00:00
httplib
indexer fix: Elasticsearch: Request Entity Too Large #28117 (#29062) 2024-02-07 08:57:16 +00:00
issue/template
json
label
lfs Update tool dependencies (#29030) 2024-02-02 19:11:39 -05:00
log
markup Refactor markup rendering to accept general "protocol:" prefix (#29276) 2024-02-21 10:08:08 +00:00
mcaptcha
metrics
migration Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
nosql
optional Unify user update methods (#28733) 2024-02-04 13:29:09 +00:00
options
packages Propagate install_if and provider_priority to APKINDEX (#28899) 2024-02-05 05:52:56 +00:00
paginator
pprof
private Return responseText instead of string in some functions (#28836) 2024-01-19 10:45:23 +08:00
process Replace assert.Fail with assert.FailNow (#27578) 2023-10-11 11:02:24 +00:00
proxy
proxyprotocol
public Refactor CORS handler (#28587) 2023-12-25 20:13:18 +08:00
queue Increase queue length (#27555) 2023-10-10 18:47:49 +08:00
recaptcha
references Add support for sha256 repositories (#23894) 2024-01-19 17:05:02 +01:00
regexplru
repository Always write proc-receive hook for all git versions (#29287) 2024-02-21 07:01:48 +00:00
secret
session
setting Use general token signing secret (#29205) 2024-02-18 17:39:04 +00:00
sitemap
ssh Remove SSH workaround (#27893) 2023-11-03 15:21:05 +00:00
storage
structs Add merge style fast-forward-only (#28954) 2024-02-12 23:37:23 +01:00
svg
sync
system Replace more db.DefaultContext (#27628) 2023-10-15 17:46:06 +02:00
templates Refactor more code in templates (#29236) 2024-02-18 10:52:02 +01:00
test
testlogger
timeutil Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
translation Improve TrHTML and add more tests (#29228) 2024-02-18 12:15:24 +00:00
turnstile
typesniffer
updatechecker Replace more db.DefaultContext (#27628) 2023-10-15 17:46:06 +02:00
upload
uri
user
util Refactor JWT secret generating & decoding code (#29172) 2024-02-16 15:18:30 +00:00
validation
web Refactor locale&string&template related code (#29165) 2024-02-14 21:48:45 +00:00
webhook Fix schedule tasks bugs (#28691) 2024-01-12 21:50:38 +00:00