apply: do not barf on patch with too large an offset

Previously a patch that records too large a line number caused the
offset matching code in git-apply to overstep its internal buffer.

Noticed by Johannes Schindelin.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2008-02-11 15:32:29 -08:00
parent b2979ff599
commit 52f3c81a9d
2 changed files with 60 additions and 0 deletions

View File

@ -1809,6 +1809,9 @@ static int find_pos(struct image *img,
else if (match_end)
line = img->nr - preimage->nr;
if (line > img->nr)
line = img->nr;
try = 0;
for (i = 0; i < line; i++)
try += img->line[i].len;