Re: [PATCH 1/1] attr: enable attr pathspec magic for git-add and git-stash
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 2, 2023, 23:45 UTC
- Message-ID
- <xmqq34xnlny7.fsf@gitster.g>
- In-Reply-To
- <xmqqil6jlu3m.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
>> + } else {
>> + /* For an element in longhand form, we simply copy everything up to the final ')' */
>
> A comment that is a bit on the overly-long side.
>
>> + int len = strchr(element, ')') - element;
>> + strbuf_add(sb, element, len);In practice, nobody sane would write a pathspec magic that is over 2GB in size, so this would not matter unless we are facing a potential attacker, but as the third parameter strbuf_add() takes is of type size_t, it would not hurt to define "len" as the same type as well.
> Thanks for working on fixing this rather old bug. I think we should > have noticed when we added the support for the "attr" magic to the > pathspec API.