Author: pfg Date: Sun Jul 31 04:58:06 2016 New Revision: 303571 URL: https://svnweb.freebsd.org/changeset/base/303571
Log: indent(1): Bail out if there's no more space on the parser stack. Also increase the stack size still keeping a conservative value of 256. This is based on a similar changes done for PostgreSQL which instead uses a stack size of 1000. Differential Revision: https://reviews.freebsd.org/D6966 (Partial) Submitted by: Piotr Stefaniak (with changes) Modified: head/usr.bin/indent/indent_globs.h head/usr.bin/indent/parse.c Modified: head/usr.bin/indent/indent_globs.h ============================================================================== --- head/usr.bin/indent/indent_globs.h Sun Jul 31 04:14:20 2016 (r303570) +++ head/usr.bin/indent/indent_globs.h Sun Jul 31 04:58:06 2016 (r303571) @@ -226,7 +226,7 @@ struct fstate bodyf; /* major body font */ -#define STACKSIZE 150 +#define STACKSIZE 256 struct parser_state { int last_token; Modified: head/usr.bin/indent/parse.c ============================================================================== --- head/usr.bin/indent/parse.c Sun Jul 31 04:14:20 2016 (r303570) +++ head/usr.bin/indent/parse.c Sun Jul 31 04:58:06 2016 (r303571) @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)parse.c 8.1 #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <err.h> #include <stdio.h> #include "indent_globs.h" #include "indent_codes.h" @@ -200,6 +201,9 @@ parse(int tk) /* tk: the code for the co } /* end of switch */ + if (ps.tos >= STACKSIZE) + errx(1, "Parser stack overflow"); + reduce(); /* see if any reduction can be done */ #ifdef debug _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"