Re: [PATCH v4 13/16] builtin/blame: fix type of `length` variable when emitting object ID
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Jan 9, 2025, 06:20 UTC
- Message-ID
- <Z39quLJkI42TwuaW@pks.im>
- In-Reply-To
- <4d812802-afbc-4635-7a19-73896fcda625@gmx.de>
On Wed, Jan 08, 2025 at 08:17:23PM +0100, Johannes Schindelin wrote:
Show 17 quoted lines
> On Fri, 6 Dec 2024, Patrick Steinhardt wrote:
> > @@ -501,7 +505,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
> > length--;
> > putchar('?');
> > }
> > - printf("%.*s", length, hex);
> > + fwrite(hex, 1, length, stdout);
>
> I just noticed this, and would like to point out a difference of behavior.
> Try this at home:
>
> git blame --abbrev=99999 git.c
>
> The difference relative to the previous behavior that I am observing is
> that the `fwrite()` call does not stop at the NUL character and hence
> happily continues out-of-bounds. The `printf()` call would have stopped at
> the NUL character.Oof, of course, that's an embarassing one. I'll post a patch in a bit. Thanks!
Patrick