summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-07-13 18:24:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-07-13 18:24:15 (GMT)
commitc510926691f7aa62248fa3757dea826874153b1d (patch)
tree9c511b96e3f4461d30f486649e5851eb61e8d1da /commit.c
parentce18123cec7674b58bb57272fdfa28de6ecc6b18 (diff)
parent3324dd8f267cb59cdd42ac33727b6844921d5017 (diff)
downloadgit-c510926691f7aa62248fa3757dea826874153b1d.zip
git-c510926691f7aa62248fa3757dea826874153b1d.tar.gz
git-c510926691f7aa62248fa3757dea826874153b1d.tar.bz2
Merge branch 'js/sign-empty-commit-fix'
"git commit --amend --allow-empty-message -S" for a commit without any message body could have misidentified where the header of the commit object ends. * js/sign-empty-commit-fix: commit -S: avoid invalid pointer with empty message
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/commit.c b/commit.c
index 24d4715..2a90e37 100644
--- a/commit.c
+++ b/commit.c
@@ -1092,9 +1092,14 @@ static int do_sign_commit(struct strbuf *buf, const char *keyid)
{
struct strbuf sig = STRBUF_INIT;
int inspos, copypos;
+ const char *eoh;
/* find the end of the header */
- inspos = strstr(buf->buf, "\n\n") - buf->buf + 1;
+ eoh = strstr(buf->buf, "\n\n");
+ if (!eoh)
+ inspos = buf->len;
+ else
+ inspos = eoh - buf->buf + 1;
if (!keyid || !*keyid)
keyid = get_signing_key();