From: Junio C Hamano Date: Wed, 14 Oct 2015 22:34:19 +0000 (-0700) Subject: mailinfo: fix an off-by-one error in the boundary stack X-Git-Tag: v2.7.0-rc0~64^2~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6af8ed13a73a705b79e79ecd7320f3e90e98315;p=git mailinfo: fix an off-by-one error in the boundary stack We pre-increment the pointer that we will use to store something at, so the pointer is already beyond the end of the array if it points at content[MAX_BOUNDARIES]. Signed-off-by: Junio C Hamano --- diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index addc0e00a6..1566c19b62 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -185,7 +185,7 @@ static void handle_content_type(struct strbuf *line) if (slurp_attr(line->buf, "boundary=", boundary)) { strbuf_insert(boundary, 0, "--", 2); - if (++content_top > &content[MAX_BOUNDARIES]) { + if (++content_top >= &content[MAX_BOUNDARIES]) { fprintf(stderr, "Too many boundaries to handle\n"); exit(1); }