svn commit: r303571 - head/usr.bin/indent
Pedro F. Giffuni
pfg at FreeBSD.org
Sun Jul 31 04:58:07 UTC 2016
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
More information about the svn-src-head
mailing list