From: Thomas Rast <trast@student.ethz.ch>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>, <git@vger.kernel.org>
Subject: [RFC PATCH 2a] pretty: detect missing \n\n in commit message
Date: Tue, 28 Feb 2012 11:37:00 +0100 [thread overview]
Message-ID: <5234ba4babd28d9430750d227d629b4d4386b131.1330425111.git.trast@student.ethz.ch> (raw)
In-Reply-To: <010901fbfffe0f806bb19d556ebc1e512a4697f4.1330425111.git.trast@student.ethz.ch>
get_header()'s exit condition is finding the \n\n that separates the
commit header from its message. If such a double newline is not
present, it segfaults. Catch this case and die().
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
This would be the minimal fix to the pretty machinery so that 'git
rev-list --pretty=something HEAD' works when there are such broken
commits.
If 2b goes in, there isn't really any point as we would never get this
far on such a commit.
pretty.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pretty.c b/pretty.c
index 8688b8f..b7f097d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -440,7 +440,10 @@ static char *get_header(const struct commit *commit, const char *key)
const char *line = commit->buffer;
for (;;) {
- const char *eol = strchr(line, '\n'), *next;
+ const char *eol, *next;
+ if (!line)
+ die (_("malformed commit object: no separating \\n\\n?"));
+ eol = strchr(line, '\n');
if (line == eol)
return NULL;
--
1.7.9.2.467.g7fee4
next prev parent reply other threads:[~2012-02-28 10:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-28 8:57 [PATCH] commit: allow {--amend|-c foo} when {HEAD|foo} has empty message Thomas Rast
2012-02-28 9:05 ` Jeff King
2012-02-28 9:14 ` Jeff King
2012-02-28 9:20 ` Thomas Rast
2012-02-28 17:21 ` Junio C Hamano
2012-02-28 19:59 ` Jeff King
2012-02-28 21:12 ` Junio C Hamano
2012-02-28 10:36 ` [PATCH v2] " Thomas Rast
2012-02-28 10:37 ` Thomas Rast [this message]
2012-02-28 12:56 ` [RFC PATCH 2a] pretty: detect missing \n\n in commit message Nguyen Thai Ngoc Duy
2012-02-28 17:27 ` Junio C Hamano
2012-02-28 10:37 ` [RFC PATCH 2b] parse_commit: refuse to load commit without \n\n separator Thomas Rast
2012-02-28 17:25 ` [PATCH v2] commit: allow {--amend|-c foo} when {HEAD|foo} has empty message Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5234ba4babd28d9430750d227d629b4d4386b131.1330425111.git.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).