From 57fb34cf56ef4966a4e5870c418cd215d037716c Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 9 Mar 2019 21:52:34 +0000 Subject: [PATCH 1/2] Fix panic on signed empty commit message (go-gitea/gitea#6292) --- repo_commit.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/repo_commit.go b/repo_commit.go index 0d2d5e498..528991881 100644 --- a/repo_commit.go +++ b/repo_commit.go @@ -101,7 +101,11 @@ l: sig, err := newGPGSignatureFromCommitline(data, (nextline+1)+sigindex, true) if err == nil && sig != nil { // remove signature from commit message - cm = cm[:sigindex-1] + if sigindex == 0 { + cm = cm[:0] + } else { + cm = cm[:sigindex-1] + } commit.Signature = sig } } From 96e9f1604fbacc140783f3f2104d11e877abd5e7 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sat, 9 Mar 2019 23:05:20 +0000 Subject: [PATCH 2/2] Update repo_commit.go As per @lafriks --- repo_commit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo_commit.go b/repo_commit.go index 528991881..2d9f5bdbf 100644 --- a/repo_commit.go +++ b/repo_commit.go @@ -102,7 +102,7 @@ l: if err == nil && sig != nil { // remove signature from commit message if sigindex == 0 { - cm = cm[:0] + cm = "" } else { cm = cm[:sigindex-1] }