From: Jay Soffian Date: Tue, 9 Feb 2010 03:48:13 +0000 (-0500) Subject: blame: prevent a segv when -L given start > EOF X-Git-Tag: v1.6.6.2~1^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=92f9e273e86d505e4c2a28bc053eb514ca2cc552;p=git.git blame: prevent a segv when -L given start > EOF blame would segv if given -L with past the end of the file. While we're fixing the bug, add test cases for an invalid when called as -L , or -L. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- diff --git a/builtin-blame.c b/builtin-blame.c index 98e818ce6..4094f3c06 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -2432,7 +2432,7 @@ parse_done: if (top < 1) top = lno; bottom--; - if (lno < top) + if (lno < top || lno < bottom) die("file %s has only %lu lines", path, lno); ent = xcalloc(1, sizeof(*ent)); diff --git a/t/t8003-blame.sh b/t/t8003-blame.sh index ad834f200..4a8db74f7 100755 --- a/t/t8003-blame.sh +++ b/t/t8003-blame.sh @@ -157,4 +157,12 @@ EOF git --no-pager blame $COMMIT -- uno >/dev/null ' +test_expect_success 'blame -L with invalid start' ' + test_must_fail git blame -L5 tres 2>&1 | grep "has only 2 lines" +' + +test_expect_success 'blame -L with invalid end' ' + git blame -L1,5 tres 2>&1 | grep "has only 2 lines" +' + test_done