summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-02-02 18:57:59 +0300
committerSasha Levin <sashal@kernel.org>2024-03-27 01:22:02 +0300
commit87ddba29e72be6b6594c26d0f9388346d30e5bf1 (patch)
tree6eb3622d437f1efa71d61fb96258c06398239d46 /scripts
parent1639e9c7a3ae7e4ce6b5917aeb2b480d2e3ccf64 (diff)
downloadlinux-87ddba29e72be6b6594c26d0f9388346d30e5bf1.tar.xz
kconfig: fix infinite loop when expanding a macro at the end of file
[ Upstream commit af8bbce92044dc58e4cc039ab94ee5d470a621f5 ] 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: 104daea149c4 ("kconfig: reference environment variables directly and remove 'option env='") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/lexer.l7
1 files changed, 5 insertions, 2 deletions
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
index 240109f965ae..72e5e9ac52bb 100644
--- a/scripts/kconfig/lexer.l
+++ b/scripts/kconfig/lexer.l
@@ -305,8 +305,11 @@ static char *expand_token(const char *in, size_t n)
new_string();
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') {
unput(c);
break;