Re: [PATCH] commit.c: ensure strchrnul() doesn't scan beyond range
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 6, 2024, 18:44 UTC
- Message-ID
- <xmqqwmrhh1q2.fsf@gitster.g>
- In-Reply-To
- <ce83bd09-dbd2-4c9e-8197-6e4800935523@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 7 quoted lines
>> while (line && line < msg + len) {
>> const char *eol = strchrnul(line, '\n');
>> + assert(eol - line <= len);
>
> Something like this might work in Verse, but C is more simple-minded.
> You can't undo an out-of-bounds access after the fact, and assert()
> would be compiled out if the code is built with NDEBUG anyway.Good comments. Thanks.