From owner-svn-src-head@freebsd.org Sun Jul 31 04:58:07 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C7618BA8DB4; Sun, 31 Jul 2016 04:58:07 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 97869134A; Sun, 31 Jul 2016 04:58:07 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6V4w6TS081988; Sun, 31 Jul 2016 04:58:06 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6V4w6og081986; Sun, 31 Jul 2016 04:58:06 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201607310458.u6V4w6og081986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sun, 31 Jul 2016 04:58:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303571 - head/usr.bin/indent X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Jul 2016 04:58:07 -0000 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 __FBSDID("$FreeBSD$"); +#include #include #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