From: Patrick Steinhardt Date: Thu, 09 Jan 2025 06:20:48 GMT Subject: Re: [PATCH v4 13/16] builtin/blame: fix type of `length` variable when emitting object ID Message-ID: In-Reply-To: <4d812802-afbc-4635-7a19-73896fcda625@gmx.de> On Wed, Jan 08, 2025 at 08:17:23PM +0100, Johannes Schindelin wrote: > 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