diff options
| author | Linus Torvalds <torvalds@home.transmeta.com> | 2003-06-21 11:03:36 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:00:53 -0700 |
| commit | 096f85e4aaca809dade8d9d653ce085f407683a2 (patch) | |
| tree | d313306da24f576580704633fe69e479b0d63fbe /pre-process.c | |
| parent | b71b05cdc93efe54ecea639d6cae4c991ed2c999 (diff) | |
| download | sparse-dev-096f85e4aaca809dade8d9d653ce085f407683a2.tar.gz | |
Fix a nonchecked (and much too small) nesting level limit.
Diffstat (limited to 'pre-process.c')
| -rw-r--r-- | pre-process.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/pre-process.c b/pre-process.c index c39d9965..1eda9688 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++; |
