From: Erkan Erdem <hexvalid@gmail.com>
To: Nathan Chancellor <nathan@kernel.org>, Nicolas Schier <nsc@kernel.org>
Cc: Erkan Erdem <hexvalid@gmail.com>,
Julian Braha <julianbraha@gmail.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] kconfig: preserve the final answer when input has no newline
Date: Sat, 5 Sep 2026 15:32:21 +0300 [thread overview]
Message-ID: <20260905123237.40670-1-hexvalid@gmail.com> (raw)
conf_string() unconditionally removes the last character returned by
fgets(), assuming that it is a newline. When redirected input ends
without a newline, the last character is part of the answer instead.
For example, feeding 42 to an integer prompt stores 4, and feeding
0xff to a hexadecimal prompt stores 0xf. Both commands succeed despite
silently changing the supplied value.
Strip the newline with strcspn() so that a complete answer at EOF is
preserved. Keep the existing handling of newline-terminated and empty
answers unchanged.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by: LLM
Signed-off-by: Erkan Erdem <hexvalid@gmail.com>
---
An AI coding assistant found the issue, prepared the fix and changelog,
and ran the verification below after a request to find reproducible
functional bugs in Linux development tools.
Validation:
- Built conf with Clang on macOS and GCC in an x86_64 Linux container,
using -Wall -Wmissing-prototypes -Wstrict-prototypes -Werror.
- Ran 60 before/after executions on each platform, covering oldaskconfig
and oldconfig with string, int and hex answers. Unterminated answers
retain their last character. Newline, empty-answer, empty-input and
CRLF controls keep the same results.
- The 21 existing Kconfig tests pass on macOS.
- This tests the host configuration tool; a complete kernel was not built.
scripts/kconfig/conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fe8ba09b..46c9ca64 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -343,7 +343,7 @@ static int conf_string(struct menu *menu)
}
/* fall through */
default:
- line[strlen(line)-1] = 0;
+ line[strcspn(line, "\n")] = 0;
def = line;
}
if (def && sym_set_string_value(sym, def))
base-commit: 4d7d9486c04d917265f64c55bd23b2cc4fe7749c
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-09-05 12:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-05 12:32 Erkan Erdem [this message]
2026-09-05 12:32 ` [PATCH 2/2] checkkconfigsymbols: resolve revisions before resetting the tree Erkan Erdem
2026-09-05 14:11 ` Julian Braha
2026-09-05 14:11 ` [PATCH 1/2] kconfig: preserve the final answer when input has no newline Julian Braha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260905123237.40670-1-hexvalid@gmail.com \
--to=hexvalid@gmail.com \
--cc=julianbraha@gmail.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=nsc@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®