Re: [PATCH 01/11] mingw: avoid accessing uninitialized memory in `is_executable()`
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 16, 2022, 20:20 UTC
- Message-ID
- <xmqqilp0s6lk.fsf@gitster.g>
- In-Reply-To
- <xmqqmtecs6ws.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
>> Hmm, but buf _is_ initialized fully? Line 149:
>>
>> char buf[3] = { 0 };
>
> Ahh, yeah, that changes the landscape quite a bit.Just for reference, this piece of code has been correct ever since it was introduced to help.c by cc3b7a97 (Windows: Make 'git help -a' work., 2008-01-14). With a larger context, we can see buf[3] that is NUL filled, which receives 2 bytes by read(), and strcmp() does look semantically more correct than memcmp(), even though there probably shouldn't be any correctness or performance difference.
So, strcmp -> memcmp in this case is a strict dis-improvement. I merged it already to 'next', but I haven't pushed the result out, so I'll redo 'next' before I push the result out.
Thanks.