aboutsummaryrefslogtreecommitdiff
path: root/builtin-mailinfo.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-08-19 13:28:24 -0400
committerJunio C Hamano <gitster@pobox.com>2008-08-19 19:36:56 -0700
commite9d7d10a7f17fb9cc6a4d37b6fdf27170f4deede (patch)
treefd6d405f55a76858d0437a3fba201c17b8a0d975 /builtin-mailinfo.c
parentc8c4450e1949055cb57e32425b125f45f3481742 (diff)
downloadgit-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 'builtin-mailinfo.c')
-rw-r--r--builtin-mailinfo.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 26d3e5d7a..e890f7a6d 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -107,7 +107,7 @@ static void handle_from(const struct strbuf *from)
el = strcspn(at, " \n\t\r\v\f>");
strbuf_reset(&email);
strbuf_add(&email, at, el);
- strbuf_remove(&f, at - f.buf, el + 1);
+ strbuf_remove(&f, at - f.buf, el + (at[el] ? 1 : 0));
/* The remainder is name. It could be "John Doe <john.doe@xz>"
* or "john.doe@xz (John Doe)", but we have removed the