From 25fb8ee4450b3366bf1e9536a5585341d35b7b20 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Wed, 31 Jul 2013 04:15:39 -0400 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- t/t4211-line-log.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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