diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-02-12 00:32:29 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-02-12 00:48:10 +0100 |
commit | 52f3c81a9d41af019ab8f05051c5251f078b12e5 (patch) | |
tree | 6cebba3fe821be8561a7c6ff1d648748450774c7 /builtin-apply.c | |
parent | core.whitespace: cr-at-eol (diff) | |
download | git-52f3c81a9d41af019ab8f05051c5251f078b12e5.tar.xz git-52f3c81a9d41af019ab8f05051c5251f078b12e5.zip |
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>
Diffstat (limited to 'builtin-apply.c')
-rw-r--r-- | builtin-apply.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/builtin-apply.c b/builtin-apply.c index 2b8ba81d81..5ed4e918c0 100644 --- a/builtin-apply.c +++ b/builtin-apply.c @@ -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; |