Re: [PATCH v4 13/16] builtin/blame: fix type of `length` variable when emitting object ID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux