diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-03-05 16:16:54 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:01:28 -0700 |
| commit | a4d68b35cce58b38659adef35df4fe529c3d5680 (patch) | |
| tree | 50784d0202d8837c55f7819f8920ebcea5715560 /pre-process.c | |
| parent | dcda4aecd5eddf0001417fc20dd530bb3154f654 (diff) | |
| download | sparse-dev-a4d68b35cce58b38659adef35df4fe529c3d5680.tar.gz | |
Fix token expansion array overflow.
Diffstat (limited to 'pre-process.c')
| -rw-r--r-- | pre-process.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pre-process.c b/pre-process.c index 4e18cd83..d2dc2a8f 100644 --- a/pre-process.c +++ b/pre-process.c @@ -825,7 +825,7 @@ static int handle_endif(struct stream *stream, struct token *head, struct token static const char *show_token_sequence(struct token *token) { - static char buffer[256]; + static char buffer[1024]; char *ptr = buffer; int whitespace = 0; @@ -834,6 +834,12 @@ static const char *show_token_sequence(struct token *token) while (!eof_token(token) && !match_op(token, SPECIAL_ARG_SEPARATOR)) { const char *val = show_token(token); int len = strlen(val); + + if (ptr + whitespace + len > buffer + sizeof(buffer)) { + warn(token->pos, "too long token expansion"); + break; + } + if (whitespace) *ptr++ = ' '; memcpy(ptr, val, len); |
