From e9d7d10a7f17fb9cc6a4d37b6fdf27170f4deede Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 19 Aug 2008 13:28:24 -0400 Subject: 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 Signed-off-by: Junio C Hamano --- t/t5100/info-from.in | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 t/t5100/info-from.in (limited to 't/t5100/info-from.in') diff --git a/t/t5100/info-from.in b/t/t5100/info-from.in new file mode 100644 index 0000000000..4f082093fc --- /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 -- cgit v1.2.3