Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent panic on git blame by limiting lines to 4096 bytes at most #13470

Merged

Conversation

zeripath
Copy link
Contributor

@zeripath zeripath commented Nov 8, 2020

This PR prevents the panic by limiting the number of bytes per line to 4096 bytes (The default buffer size for a reader)

Fix #12440
Closes #13192

Signed-off-by: Andrew Thornton art27@cantab.net

Fix go-gitea#12440
Closes go-gitea#13192

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

zeripath commented Nov 8, 2020

There is a potentially nicer solution here - limit the lines to 1024 or possibly a fewer number of runes and create an expansion button. However this PR presents the simplest fix to prevent the panic.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 8, 2020
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 9, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 9, 2020
@6543
Copy link
Member

6543 commented Nov 9, 2020

works nicely

@6543 6543 added the backport/done All backports for this PR have been created label Nov 9, 2020
@6543
Copy link
Member

6543 commented Nov 10, 2020

🚀

@codecov-io
Copy link

Codecov Report

Merging #13470 (eea6584) into master (77e5081) will increase coverage by 0.13%.
The diff coverage is 52.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13470      +/-   ##
==========================================
+ Coverage   42.05%   42.19%   +0.13%     
==========================================
  Files         694      694              
  Lines       76334    76347      +13     
==========================================
+ Hits        32105    32212     +107     
+ Misses      38971    38857     -114     
- Partials     5258     5278      +20     
Impacted Files Coverage Δ
modules/git/blame.go 65.71% <52.38%> (-9.73%) ⬇️
modules/log/event.go 58.96% <0.00%> (-0.95%) ⬇️
models/gpg_key.go 53.33% <0.00%> (-0.58%) ⬇️
models/error.go 35.72% <0.00%> (+0.50%) ⬆️
services/pull/pull.go 41.27% <0.00%> (+0.98%) ⬆️
services/mailer/mail.go 61.29% <0.00%> (+1.07%) ⬆️
models/repo_language_stats.go 63.47% <0.00%> (+1.73%) ⬆️
services/pull/check.go 51.09% <0.00%> (+2.18%) ⬆️
modules/notification/notification.go 86.60% <0.00%> (+2.67%) ⬆️
modules/notification/base/null.go 77.14% <0.00%> (+2.85%) ⬆️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77e5081...eea6584. Read the comment docs.

@techknowlogick
Copy link
Member

🚀

@techknowlogick techknowlogick merged commit 182b5a0 into go-gitea:master Nov 10, 2020
techknowlogick added a commit to techknowlogick/gitea that referenced this pull request Nov 10, 2020
…o-gitea#13470)

Fix go-gitea#12440
Closes go-gitea#13192

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
techknowlogick added a commit to techknowlogick/gitea that referenced this pull request Nov 10, 2020
…o-gitea#13470)

Fix go-gitea#12440
Closes go-gitea#13192

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@zeripath zeripath deleted the fix-12440-prevent-panic-on-git-blame branch November 10, 2020 08:03
@zeripath zeripath mentioned this pull request Nov 10, 2020
7 tasks
@go-gitea go-gitea locked and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic in git blame
6 participants