]> git.ipfire.org Git - thirdparty/git.git/commit - attr.c
attr: harden allocation against integer overflows
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Dec 2022 14:45:40 +0000 (15:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Dec 2022 06:14:16 +0000 (15:14 +0900)
commita60a66e409c265b2944f18bf43581c146812586d
treed1a9f9b53d8b13dd6e91b127b442be813c6f2167
parente1e12e97ac73ded85f7d000da1063a774b3cc14f
attr: harden allocation against integer overflows

When parsing an attributes line, we need to allocate an array that holds
all attributes specified for the given file pattern. The calculation to
determine the number of bytes that need to be allocated was prone to an
overflow though when there was an unreasonable amount of attributes.

Harden the allocation by instead using the `st_` helper functions that
cause us to die when we hit an integer overflow.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
attr.c