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

"slice bounds out of range error" in signature_nogogit.go due to an empty author name #21900

Closed
ghost opened this issue Nov 22, 2022 · 0 comments · Fixed by #21902
Closed

"slice bounds out of range error" in signature_nogogit.go due to an empty author name #21900

ghost opened this issue Nov 22, 2022 · 0 comments · Fixed by #21902
Labels

Comments

@ghost
Copy link

ghost commented Nov 22, 2022

Description

Not sure how it happened, I have commits without an author name in a repository.

commit ea187914379a3137a46784c716307a2844dbe744
Author:  <[email protected]>
Date:   Thu Mar 27 12:51:29 2008 +0100

Pushing this repository will lead to a 500 error when visiting the repository page on gitea, due to the following exception :

2022/11/22 17:58:15 routers/web/base.go:135:1() [E] [637cffa7] PANIC: runtime error: slice bounds out of range [:-1]
/usr/lib/go-1.19/src/runtime/panic.go:139 (0x4404be)
	goPanicSliceAcap: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsSliceAcap})
/home/aot/src/gitea/modules/git/signature_nogogit.go:54 (0x100bc3c)
	newSignatureFromCommitline: sig.Name = string(line[:emailStart-1])
/home/aot/src/gitea/modules/git/signature_nogogit.go:33 (0xfbfa5c)
	(*Signature).Decode: sig, _ := newSignatureFromCommitline(b)
/home/aot/src/gitea/modules/git/commit_reader.go:82 (0xfbfa45)
	CommitFromReader: commit.Author.Decode(data)
/home/aot/src/gitea/modules/git/repo_commit_nogogit.go:117 (0xff34c8)
	(*Repository).getCommitFromBatchReader: commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size))
/home/aot/src/gitea/modules/git/repo_commit_nogogit.go:75 (0xff329b)
	(*Repository).getCommit: return repo.getCommitFromBatchReader(rd, id)
/home/aot/src/gitea/modules/git/repo_commit.go:37 (0xfe57c4)
	(*Repository).GetCommit: return repo.getCommit(id)
/home/aot/src/gitea/modules/git/repo_commit.go:46 (0xfe586d)
	(*Repository).GetBranchCommit: return repo.GetCommit(commitID)
/home/aot/src/gitea/modules/context/repo.go:945 (0x1ae41a4)
	RepoRefByType.func1: ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(refName)
/home/aot/src/gitea/modules/web/wrap_convert.go:55 (0x1eea8f3)
	convertHandler.func4: deferrable = t(ctx)
/home/aot/src/gitea/modules/web/wrap.go:41 (0x1ee8ec4)
	wrapInternal.func1: done, deferrable := handler(resp, req, others...)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 (0x1ac3835)
	(*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/web/wrap.go:63 (0x1ee9308)
	Middle.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/web/wrap.go:63 (0x1ee9308)
	Middle.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/web/wrap.go:63 (0x1ee9308)
	Middle.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/get_head.go:37 (0x1fafd6d)
	GetHead.func1: next.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/web/wrap.go:63 (0x1ee9308)
	Middle.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/context/context.go:806 (0x1ad7dfa)
	Contexter.func1.1: next.ServeHTTP(ctx.Resp, ctx.Req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 (0x1ac15f4)
	(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 (0x1ac2ffb)
	(*Mux).Mount.func1: handler.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 (0x1ac3835)
	(*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/routers/web/base.go:175 (0x218c6d1)
	Recovery.func1.1: next.ServeHTTP(w, req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/gitea.com/go-chi/[email protected]/session.go:257 (0x125d3ea)
	Sessioner.func1.1: next.ServeHTTP(w, req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/web/wrap.go:110 (0x1ee9cc8)
	WrapWithPrefix.func1.1: next.ServeHTTP(resp, req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:71 (0x1ac15f4)
	(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:314 (0x1ac2ffb)
	(*Mux).Mount.func1: handler.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:442 (0x1ac3835)
	(*Mux).routeHTTP: h.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/routers/common/middleware.go:79 (0x1fb53a2)
	Middlewares.func2.1: next.ServeHTTP(resp, req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/modules/web/routing/logger_manager.go:123 (0x1ee4bd3)
	(*requestRecordsManager).handler.func1: next.ServeHTTP(w, req)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/middleware/strip.go:30 (0x1fb2c38)
	StripSlashes.func1: next.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/chi-middleware/[email protected]/middleware.go:37 (0x1faf3d6)
	ForwardedHeaders.func1.1: h.ServeHTTP(w, r)
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/src/gitea/routers/common/middleware.go:32 (0x1fb51f1)
	Middlewares.func1.1: next.ServeHTTP(context.NewResponse(resp), req.WithContext(ctx))
/usr/lib/go-1.19/src/net/http/server.go:2109 (0x94fcae)
	HandlerFunc.ServeHTTP: f(w, r)
/home/aot/go/pkg/mod/github.com/go-chi/chi/[email protected]/mux.go:88 (0x1ac15af)
	(*Mux).ServeHTTP: mx.handler.ServeHTTP(w, r)
/home/aot/src/gitea/modules/web/route.go:200 (0x1ee82ed)
	(*Route).ServeHTTP: r.R.ServeHTTP(w, req)
/usr/lib/go-1.19/src/net/http/server.go:2947 (0x9530ab)
	serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/lib/go-1.19/src/net/http/server.go:1991 (0x94e786)
	(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/lib/go-1.19/src/runtime/asm_amd64.s:1594 (0x4770e0)
	goexit: BYTE	$0x90	// NOP

because emailStart == 0 in modules/git/signature_nogogit.go:54

Gitea Version

e77b764

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

2.35.1

Operating System

debian testing

How are you running Gitea?

Built from source.

Database

SQLite

@ghost ghost added the type/bug label Nov 22, 2022
zeripath added a commit to zeripath/gitea that referenced this issue Nov 22, 2022
Although git does expect that author names should be of the form:
`NAME <EMAIL>` some users have been able to create commits with:
`<EMAIL>`

Fix go-gitea#21900

Signed-off-by: Andrew Thornton <[email protected]>
lunny added a commit that referenced this issue Nov 23, 2022
Although git does expect that author names should be of the form: `NAME
<EMAIL>` some users have been able to create commits with: `<EMAIL>`

Fix #21900

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: delvh <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Dec 4, 2022
Backport go-gitea#21902

Although git does expect that author names should be of the form: `NAME
<EMAIL>` some users have been able to create commits with: `<EMAIL>`

Fix go-gitea#21900

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Dec 4, 2022
Backport go-gitea#21902

Although git does expect that author names should be of the form: `NAME
<EMAIL>` some users have been able to create commits with: `<EMAIL>`

Fix go-gitea#21900

Signed-off-by: Andrew Thornton <[email protected]>
lunny pushed a commit that referenced this issue Dec 6, 2022
Backport #21902

Although git does expect that author names should be of the form: `NAME
<EMAIL>` some users have been able to create commits with: `<EMAIL>`

Fix #21900

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
lunny added a commit that referenced this issue Dec 6, 2022
Backport #21902

Although git does expect that author names should be of the form: `NAME
<EMAIL>` some users have been able to create commits with: `<EMAIL>`

Fix #21900

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 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.

0 participants