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

Uploading files to a web page will cause the repository instance to crash #26509

Closed
Lingoing opened this issue Aug 15, 2023 · 13 comments · Fixed by #26517
Closed

Uploading files to a web page will cause the repository instance to crash #26509

Lingoing opened this issue Aug 15, 2023 · 13 comments · Fixed by #26517
Labels
Milestone

Comments

@Lingoing
Copy link

Lingoing commented Aug 15, 2023

Description

Click Submit changes when the file is over 3MB, will corrupt the repository instance, want to fix this Bug.

This Bug only occurs when the repository is empty, and does not occur if there are any files in the repository such as "README.MD"

Gitea Version

v1.20.0、v1.20.2

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

11111
2222
333

Git Version

git version 2.37.1.windows.1

Operating System

Ubuntu18.04LTS

How are you running Gitea?

Binary file
http://ip:port

Database

SQLite

@CaiCandong
Copy link
Member

@Lingoing
Copy link
Author

File upload size can be set in the configuration file, the default is 3MB https://docs.gitea.com/zh-cn/next/administration/config-cheat-sheet#%E4%BB%93%E5%BA%93---%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0-repositoryupload

Which is the configuration item?

@CaiCandong
Copy link
Member

;[repository.upload]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Whether repository file uploads are enabled. Defaults to `true`
;ENABLED = true
;;
;; Path for uploads. Defaults to `data/tmp/uploads` (content gets deleted on gitea restart)
;TEMP_PATH = data/tmp/uploads
;;
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
;ALLOWED_TYPES =
;;
;; Max size of each file in megabytes. Defaults to 3MB
;FILE_MAX_SIZE = 3
;;
;; Max number of files per upload. Defaults to 5
;MAX_FILES = 5

@Lingoing
Copy link
Author

;[repository.upload]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Whether repository file uploads are enabled. Defaults to `true`
;ENABLED = true
;;
;; Path for uploads. Defaults to `data/tmp/uploads` (content gets deleted on gitea restart)
;TEMP_PATH = data/tmp/uploads
;;
;; Comma-separated list of allowed file extensions (`.zip`), mime types (`text/plain`) or wildcard type (`image/*`, `audio/*`, `video/*`). Empty value or `*/*` allows all types.
;ALLOWED_TYPES =
;;
;; Max size of each file in megabytes. Defaults to 3MB
;FILE_MAX_SIZE = 3
;;
;; Max number of files per upload. Defaults to 5
;MAX_FILES = 5

Thank you very much!

@yp05327
Copy link
Contributor

yp05327 commented Aug 15, 2023

Maybe we need a check for commit changes in the background when user uploaded a big size file over the limit?

@Lingoing
Copy link
Author

Maybe we need a check for commit changes in the background when user uploaded a big size file over the limit?

Let me modify the Bug description

@CaiCandong
Copy link
Member

Click Submit changes when the file is over 3MB, will corrupt the repository instance, want to fix this Bug

how to reproduce it? I tried it in my local server and nothing happens

@Lingoing
Copy link
Author

Click Submit changes when the file is over 3MB, will corrupt the repository instance, want to fix this Bug

how to reproduce it? I tried it in my local server and nothing happens

Try it with a file of about 300MB

@CaiCandong
Copy link
Member

Try it with a file of about 300MB

I try a file with 200MB , nothing happens . please contact me in qq group 328432459

@Lingoing
Copy link
Author

Try it with a file of about 300MB

I try a file with 200MB , nothing happens . please contact me in qq group 328432459

Yes. Go through

@KazzmanK
Copy link
Contributor

KazzmanK commented Aug 15, 2023

So, if you add an issue`s attachment - it will just show size cap error,
if you add new file as a part of commit, it will show error and will break repository?

@Lingoing
Copy link
Author

So, if you add an issue`s attachment - it will just show size cap error, if you add new file as a part of commit, it will show error and will break repository?

Yes

@CaiCandong
Copy link
Member

Reproduce Steps

  1. Create an empty repo(without init)
  2. Upload a File

Screenshot

after

Logs

2023/08/15 16:48:58 .../context_response.go:68:HTML() [D] Template: repo/editor/upload
2023/08/15 16:48:58 ...eb/routing/logger.go:102:func1() [I] router: completed GET /caicandong/test/_upload/main/ for 127.0.0.1:63337, 200 OK in 172.7ms @ repo/editor.go:583(repo.UploadFile)
2023/08/15 16:48:58 ...eb/routing/logger.go:102:func1() [I] router: completed GET /avatar/2a1b1ab96878ebecbbb2fbc271332297?size=96 for [::1]:63365, 303 See Other in 7.9ms @ user/avatar.go:48(user.AvatarByEmailHash)
2023/08/15 16:49:04 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse
2023/08/15 16:49:04 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch
2023/08/15 16:49:04 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= for-each-ref "--format=%(objectname) %(refname)" refs/heads/ --sort=-committerdate
2023/08/15 16:49:04 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= symbolic-ref HEAD
2023/08/15 16:49:04 ...ules/context/repo.go:993:func1() [D] RepoRef invalid repo: branch or tag not exist:
2023/08/15 16:49:04 .../context_response.go:68:HTML() [D] Template: status/404
2023/08/15 16:49:04 ...eb/routing/logger.go:102:func1() [I] router: completed GET /caicandong/test/src/branch/main/ for [::1]:63365, 404 Not Found in 259.8ms @ context/repo.go:878(web.registerRoutes.func39.20.RepoRefByType)
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse  
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch-check
2023/08/15 16:49:06 ...repository/branch.go:25:SyncRepoBranches() [D] SyncRepoBranches: in Repo[35:caicandong/test]
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= rev-parse  
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= cat-file --batch-check
2023/08/15 16:49:06 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= for-each-ref "--format=%(objectname) %(refname)" refs/heads/ --sort=-committerdate
2023/08/15 16:49:07 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= symbolic-ref HEAD
2023/08/15 16:49:07 ...dules/git/command.go:281:Run() [D] git.Command.RunDir(D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git): "C:\\Program Files\\Git\\cmd\\git.exe" -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= for-each-ref "--format=%(objectname) %(refname)" refs/heads/ --sort=-committerdate
2023/08/15 16:49:07 ...ules/context/repo.go:917:func4() [E] No branches in non-empty repository D:\code\golang_code\gitea\data\gitea-repositories\caicandong\test.git
2023/08/15 16:49:07 ...ules/context/repo.go:931:func4() [E] GetBranchCommit: object does not exist [id: refs/heads/main, rel_path: ]

@lunny lunny added this to the 1.20.3 milestone Aug 15, 2023
GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Aug 17, 2023
wxiaoguang added a commit that referenced this issue Aug 17, 2023
Backport #26517 by @wxiaoguang

Close #26509

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants