Re: [PATCH v3 2/2] builtin/blame: fix out-of-bounds write with blank boundary commits
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 10, 2025, 14:21 UTC
- Message-ID
- <xmqq5xmmagvv.fsf@gitster.g>
- In-Reply-To
- <992502eb-5131-228e-1915-a35038211f4b@gmx.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 20 quoted lines
> On Fri, 10 Jan 2025, Patrick Steinhardt wrote:
>
>> diff --git a/builtin/blame.c b/builtin/blame.c
>> index d7630ac89cb7bd6e9ce5d72c6a98aa433b3b12da..7555c445abe7ca2fa54670ac8fee1d95a6dbafe3 100644
>> --- a/builtin/blame.c
>> +++ b/builtin/blame.c
>> @@ -489,9 +489,9 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
>> fputs(color, stdout);
>>
>> if (suspect->commit->object.flags & UNINTERESTING) {
>> - if (blank_boundary)
>> - memset(hex, ' ', length);
>> - else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
>> + if (blank_boundary) {
>> + memset(hex, ' ', strlen(hex));
>
> Using `strlen()` is a neat trick.
>
> I could have done without slipping in a style change (introducing
> curlies), but the most important thing is that it fixes the bug.Thank both of you for these last-minute fixes. Hopefully we can have them in today's release, and we didn't miss unexpected side effects in them, I hope ;-).