aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2003-06-21 11:03:36 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:53 -0700
commit096f85e4aaca809dade8d9d653ce085f407683a2 (patch)
treed313306da24f576580704633fe69e479b0d63fbe
parentb71b05cdc93efe54ecea639d6cae4c991ed2c999 (diff)
downloadsparse-096f85e4aaca809dade8d9d653ce085f407683a2.tar.gz
sparse-096f85e4aaca809dade8d9d653ce085f407683a2.tar.xz
sparse-096f85e4aaca809dade8d9d653ce085f407683a2.zip
Fix a nonchecked (and much too small) nesting level limit.
-rw-r--r--pre-process.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/pre-process.c b/pre-process.c
index c39d996..1eda968 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -28,11 +28,11 @@
int verbose = 0;
int preprocessing = 0;
-#define MAXNEST (16)
+#define MAX_NEST (256)
static int true_nesting = 0;
static int false_nesting = 0;
static struct token *unmatched_if = NULL;
-static int elif_ignore[MAXNEST];
+static char elif_ignore[MAX_NEST];
#define if_nesting (true_nesting + false_nesting)
#define INCLUDEPATHS 32
@@ -679,6 +679,8 @@ static int preprocessor_if(struct token *token, int true)
{
if (if_nesting == 0)
unmatched_if = token;
+ if (if_nesting >= MAX_NEST)
+ error(token->pos, "Maximum preprocessor conditional level exhausted");
elif_ignore[if_nesting] = false_nesting || true;
if (false_nesting || !true) {
false_nesting++;