git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonathan del Strother" <maillist@steelskies.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: "Alex Riesen" <raa.lkml@gmail.com>, git@vger.kernel.org
Subject: Re: Serious bug with pretty format strings & empty bodies?
Date: Thu, 20 Dec 2007 13:08:37 +0000	[thread overview]
Message-ID: <57518fd10712200508x4b15f9acy10aed83a3cebeba@mail.gmail.com> (raw)
In-Reply-To: <476A5DFF.40803@lsrfire.ath.cx>

On Dec 20, 2007 12:20 PM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
> Jonathan del Strother schrieb:
> > On Dec 19, 2007 11:23 PM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
> >> Just a shot in the dark: does this patch on top of master make a difference?
> > No luck with that, I'm afraid.
>
> And how is this one?
>
> The first chunk is the same as in the last try -- it guards against commit
> messages ending with a NUL without a prior \n _and_ being followed by a \n
> (in memory which shouldn't be accessed by us at all as it doesn't belong to
> the commit message).  I guess that's quite rare.
>
> The second chunk keeps the body offset from being incremented by the for
> loop if we've already found a terminating NUL.
>
> diff --git a/pretty.c b/pretty.c
> index 9db75b4..5b1078b 100644
> --- a/pretty.c
> +++ b/pretty.c
> @@ -412,7 +412,7 @@ static void parse_commit_header(struct format_commit_context *context)
>                 if (i == eol) {
>                         state++;
>                         /* strip empty lines */
> -                       while (msg[eol + 1] == '\n')
> +                       while (msg[eol] == '\n' && msg[eol + 1] == '\n')
>                                 eol++;
>                 } else if (!prefixcmp(msg + i, "author ")) {
>                         context->author.off = i + 7;
> @@ -425,6 +425,8 @@ static void parse_commit_header(struct format_commit_context *context)
>                         context->encoding.len = eol - i - 9;
>                 }
>                 i = eol;
> +               if (!msg[i])
> +                       break;
>         }
>         context->body_off = i;
>         context->commit_header_parsed = 1;
>

Winnar!

Yep, that seems to have fixed things.  Wonder how I managed to get the
null into the commit message...

  parent reply	other threads:[~2007-12-20 13:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-19 14:32 Serious bug with pretty format strings & empty bodies? Jonathan del Strother
2007-12-19 18:28 ` René Scharfe
2007-12-20 10:43   ` Jonathan del Strother
2007-12-20 10:46     ` Jonathan del Strother
2007-12-19 18:44 ` Alex Riesen
2007-12-19 22:37   ` Jonathan del Strother
2007-12-19 23:23     ` René Scharfe
2007-12-20 10:44       ` Jonathan del Strother
2007-12-20 12:20         ` René Scharfe
2007-12-20 12:37           ` Johannes Schindelin
2007-12-20 13:08           ` Jonathan del Strother [this message]
2007-12-21 10:47             ` Jonathan del Strother
2007-12-22  8:39               ` Junio C Hamano
2007-12-22 15:48                 ` Jonathan del Strother
2007-12-20 11:38       ` Jonathan del Strother
2007-12-20 12:34         ` Johannes Schindelin

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=57518fd10712200508x4b15f9acy10aed83a3cebeba@mail.gmail.com \
    --to=maillist@steelskies.com \
    --cc=git@vger.kernel.org \
    --cc=raa.lkml@gmail.com \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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).