Date: Fri, 30 Dec 2016 21:00:45 +0000 (UTC) From: Piotr Pawel Stefaniak <pstef@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310863 - head/usr.bin/indent Message-ID: <201612302100.uBUL0jjC094218@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pstef Date: Fri Dec 30 21:00:45 2016 New Revision: 310863 URL: https://svnweb.freebsd.org/changeset/base/310863 Log: indent(1): Avoid out of bounds access of array ps.paren_indents ps.p_l_follow can't be allowed to grow beyond maximum index of paren_indents. Approved by: pfg (mentor) Modified: head/usr.bin/indent/indent.c Modified: head/usr.bin/indent/indent.c ============================================================================== --- head/usr.bin/indent/indent.c Fri Dec 30 20:48:22 2016 (r310862) +++ head/usr.bin/indent/indent.c Fri Dec 30 21:00:45 2016 (r310863) @@ -525,7 +525,12 @@ check_type: break; case lparen: /* got a '(' or '[' */ - ++ps.p_l_follow; /* count parens to make Healy happy */ + /* count parens to make Healy happy */ + if (++ps.p_l_follow == nitems(ps.paren_indents)) { + diag3(0, "Reached internal limit of %d unclosed parens", + nitems(ps.paren_indents)); + ps.p_l_follow--; + } if (ps.want_blank && *token != '[' && (ps.last_token != ident || proc_calls_space || /* offsetof (1) is never allowed a space; sizeof (2) gets
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612302100.uBUL0jjC094218>