Re: [PATCH] wt-status: Don't find scissors line beyond buf len
- From
Florian Schmidt <flosch@nutanix.com>
- Date
- Mar 8, 2024, 09:13 UTC
- Message-ID
- <d280a87b-e6ab-4f0d-b112-bbedc223c9fd@nutanix.com>
- In-Reply-To
- <xmqqsf11ltrt.fsf@gitster.g>
On 07/03/2024 19:35, Junio C Hamano wrote:
Show 8 quoted lines
> Florian Schmidt <flosch@nutanix.com> writes: > >> Side remark: Since strstr() doesn't consider len, and will always search >> up to a null byte, I now wonder whether it would be safer to create a >> new strbuf that only contains the len bytes we want to operate on. > > That is a valid concern in general, but does not seem to apply to > the current codebase. Thanks for being careful.
Thanks, that confirms my cursory look at the consumers of the function. If you think that it's unlikely that in the future, a new user of this function would provide a non-terminated string, then there is no need for action. I guess the aim is to use strbufs wherever suitable in the first place, anyway, and those won't have this issue?
Cheers, flosch