Skip to content
Snippets Groups Projects
Commit aa3a8cfc authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Frieder Schrempf
Browse files

kconfig: fix infinite loop when expanding a macro at the end of file


[ Upstream commit af8bbce9 ]

A macro placed at the end of a file with no newline causes an infinite
loop.

[Test Kconfig]
  $(info,hello)
  \ No newline at end of file

I realized that flex-provided input() returns 0 instead of EOF when it
reaches the end of a file.

Fixes: 104daea1 ("kconfig: reference environment variables directly and remove 'option env='")
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 6e19ed11
No related branches found
No related tags found
1 merge request!135🤖 Sync Bot: Update v5.10-ktn to Latest Stable Kernel (v5.10.214)
...@@ -305,8 +305,11 @@ static char *expand_token(const char *in, size_t n) ...@@ -305,8 +305,11 @@ static char *expand_token(const char *in, size_t n)
new_string(); new_string();
append_string(in, n); append_string(in, n);
/* get the whole line because we do not know the end of token. */ /*
while ((c = input()) != EOF) { * get the whole line because we do not know the end of token.
* input() returns 0 (not EOF!) when it reachs the end of file.
*/
while ((c = input()) != 0) {
if (c == '\n') { if (c == '\n') {
unput(c); unput(c);
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment