diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2013-07-31 04:15:39 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-08-05 11:54:31 -0700 |
commit | 25fb8ee4450b3366bf1e9536a5585341d35b7b20 (patch) | |
tree | 728dfd22e9b3888c295eb0dd0d68ebd236508c0d /t/t4211-line-log.sh | |
parent | 164a9cf4303d4a8e5c969e057adf9d700468ddc5 (diff) | |
download | git-25fb8ee4450b3366bf1e9536a5585341d35b7b20.tar.gz |
t4211: log: demonstrate -L bounds checking bug
A bounds checking bug allows the X in -LX to extend one line past the
end of file. For example, given a file with 5 lines, -L6 is accepted as
valid. Demonstrate this problem.
While here, also add tests to check that the remaining cases of X and Y
in -LX,Y are handled correctly at and in the vicinity of end-of-file.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4211-line-log.sh')
-rwxr-xr-x | t/t4211-line-log.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh index 7665d6785c..f98275c37c 100755 --- a/t/t4211-line-log.sh +++ b/t/t4211-line-log.sh @@ -64,6 +64,36 @@ test_bad_opts "-L 1,1000:b.c" "has only.*lines" test_bad_opts "-L :b.c" "argument.*not of the form" test_bad_opts "-L :foo:b.c" "no match" +test_expect_success '-L X (X == nlines)' ' + n=$(wc -l <b.c) && + git log -L $n:b.c +' + +test_expect_failure '-L X (X == nlines + 1)' ' + n=$(expr $(wc -l <b.c) + 1) && + test_must_fail git log -L $n:b.c +' + +test_expect_success '-L X (X == nlines + 2)' ' + n=$(expr $(wc -l <b.c) + 2) && + test_must_fail git log -L $n:b.c +' + +test_expect_success '-L ,Y (Y == nlines)' ' + n=$(printf "%d" $(wc -l <b.c)) && + git log -L ,$n:b.c +' + +test_expect_success '-L ,Y (Y == nlines + 1)' ' + n=$(expr $(wc -l <b.c) + 1) && + test_must_fail git log -L ,$n:b.c +' + +test_expect_success '-L ,Y (Y == nlines + 2)' ' + n=$(expr $(wc -l <b.c) + 2) && + test_must_fail git log -L ,$n:b.c +' + # There is a separate bug when an empty -L range is the first -L encountered, # thus to demonstrate this particular bug, the empty -L range must follow a # non-empty -L range. |