From: Jay Soffian <jaysoffian@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <junio@kernel.org>
Cc: Jay Soffian <jaysoffian@gmail.com>, Johannes Sixt <j.sixt@viscovery.net>
Subject: [PATCH v2] blame: prevent a segv when -L given start > EOF
Date: Tue, 9 Feb 2010 12:59:52 -0500 [thread overview]
Message-ID: <1265738392-61503-1-git-send-email-jaysoffian@gmail.com> (raw)
In-Reply-To: <4B71122F.3040809@viscovery.net>
blame would segv if given -L <lineno> with <lineno> past the end of the file.
While we're fixing the bug, add test cases for an invalid <start> when called
as -L <start>,<end> or -L<start>.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
---
Modified the tests per Hannes recommendations.
builtin-blame.c | 2 +-
t/t8003-blame.sh | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index 6408ec8..10f7eac 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2433,7 +2433,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 ad834f2..be648b2 100755
--- a/t/t8003-blame.sh
+++ b/t/t8003-blame.sh
@@ -157,4 +157,14 @@ EOF
git --no-pager blame $COMMIT -- uno >/dev/null
'
+test_expect_success 'blame -L with invalid start' '
+ test_must_fail git blame -L5 tres >output 2>&1 &&
+ grep "has only 2 lines" output
+'
+
+test_expect_success 'blame -L with invalid end' '
+ test_must_fail git blame -L1,5 tres >output 2>&1 &&
+ grep "has only 2 lines" output
+'
+
test_done
--
1.7.0.rc1.200.g9c1f9
prev parent reply other threads:[~2010-02-09 18:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-09 3:48 [PATCH] blame: prevent a segv when -L given start > EOF Jay Soffian
2010-02-09 3:50 ` Jay Soffian
2010-02-09 3:55 ` Junio C Hamano
2010-02-09 4:00 ` Jay Soffian
2010-02-09 4:02 ` Jay Soffian
2010-02-09 4:09 ` Jay Soffian
2010-02-09 5:55 ` Junio C Hamano
2010-02-09 7:43 ` Johannes Sixt
2010-02-09 17:55 ` Jay Soffian
2010-02-09 18:06 ` Junio C Hamano
2010-02-09 17:59 ` Jay Soffian [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1265738392-61503-1-git-send-email-jaysoffian@gmail.com \
--to=jaysoffian@gmail.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=junio@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).