From a4d68b35cce58b38659adef35df4fe529c3d5680 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 5 Mar 2004 16:16:54 -0700 Subject: [PATCH] Fix token expansion array overflow. --- pre-process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); -- 2.11.4.GIT