mailinfo: fix an off-by-one error in the boundary stack
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Oct 2015 22:34:19 +0000 (15:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Oct 2015 05:13:27 +0000 (22:13 -0700)
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 <gitster@pobox.com>
builtin/mailinfo.c
index addc0e00a6098a764ec94214f5f8743f146f3426..1566c19b6277b464607ddeb6ba0369383a0325ae 100644 (file)
@@ -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);
                }