]> git.ipfire.org Git - thirdparty/git.git/commit
apply: detect overflow when parsing hunk header
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 30 Jan 2025 11:08:30 +0000 (11:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Jan 2025 22:18:12 +0000 (14:18 -0800)
commita206058fdaab6274ae7b9bdca274011efba74e11
treeb9d547f041d52834980d8ea366260fe5954e4473
parent2f323bb16219c105e0c576ea4c2ece9863f5d926
apply: detect overflow when parsing hunk header

"git apply" uses strtoul() to parse the numbers in the hunk header but
silently ignores overflows. As LONG_MAX is a legitimate return value for
strtoul() we need to set errno to zero before the call to strtoul() and
check that it is still zero afterwards. The error message we display is
not particularly helpful as it does not say what was wrong.  However, it
seems pretty unlikely that users are going to trigger this error in
practice and we can always improve it later if needed.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t4100-apply-stat.sh