diff options
author | Jeff King <peff@peff.net> | 2008-08-19 13:28:24 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-19 19:36:56 -0700 |
commit | e9d7d10a7f17fb9cc6a4d37b6fdf27170f4deede (patch) | |
tree | fd6d405f55a76858d0437a3fba201c17b8a0d975 /t | |
parent | c8c4450e1949055cb57e32425b125f45f3481742 (diff) | |
download | git-e9d7d10a7f17fb9cc6a4d37b6fdf27170f4deede.tar.gz git-e9d7d10a7f17fb9cc6a4d37b6fdf27170f4deede.tar.xz |
mailinfo: avoid violating strbuf assertion
In handle_from, we calculate the end boundary of a section
to remove from a strbuf using strcspn like this:
el = strcspn(buf, set_of_end_boundaries);
strbuf_remove(&sb, start, el + 1);
This works fine if "el" is the offset of the boundary
character, meaning we remove up to and including that
character. But if the end boundary didn't match (that is, we
hit the end of the string as the boundary instead) then we
want just "el". Asking for "el+1" caught an out-of-bounds
assertion in the strbuf library.
This manifested itself when we got a 'From' header that had
just an email address with nothing else in it (the end of
the string was the end of the address, rather than, e.g., a
trailing '>' character), causing git-mailinfo to barf.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t5100-mailinfo.sh | 11 | ||||
-rw-r--r-- | t/t5100/info-from.expect | 5 | ||||
-rw-r--r-- | t/t5100/info-from.in | 8 |
3 files changed, 24 insertions, 0 deletions
diff --git a/t/t5100-mailinfo.sh b/t/t5100-mailinfo.sh index 8dfaddda9..198e3503d 100755 --- a/t/t5100-mailinfo.sh +++ b/t/t5100-mailinfo.sh @@ -43,4 +43,15 @@ test_expect_success 'Preserve NULs out of MIME encoded message' ' ' +test_expect_success 'mailinfo on from header without name works' ' + + mkdir info-from && + git mailsplit -oinfo-from "$TEST_DIRECTORY"/t5100/info-from.in && + test_cmp "$TEST_DIRECTORY"/t5100/info-from.in info-from/0001 && + git mailinfo info-from/msg info-from/patch \ + <info-from/0001 >info-from/out && + test_cmp "$TEST_DIRECTORY"/t5100/info-from.expect info-from/out + +' + test_done diff --git a/t/t5100/info-from.expect b/t/t5100/info-from.expect new file mode 100644 index 000000000..c31d2eb55 --- /dev/null +++ b/t/t5100/info-from.expect @@ -0,0 +1,5 @@ +Author: bare@example.com +Email: bare@example.com +Subject: testing bare address in from header +Date: Sun, 25 May 2008 00:38:18 -0700 + diff --git a/t/t5100/info-from.in b/t/t5100/info-from.in new file mode 100644 index 000000000..4f082093f --- /dev/null +++ b/t/t5100/info-from.in @@ -0,0 +1,8 @@ +From 667d8940e719cddee1cfe237cbbe215e20270b09 Mon Sep 17 00:00:00 2001 +From: bare@example.com +Date: Sun, 25 May 2008 00:38:18 -0700 +Subject: [PATCH] testing bare address in from header + +commit message +--- +patch |