From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796401956; b=Dic68PIlKEYboYKwlm7o0/unAAMK2nGbdkpmlxzAXyJJZvukL90dfepWtVB5dtN2nIOM z8h2mckInxhfg8X71QmOd4ztAdb5Z9cQz8rXWLsRzSyAG2RHaS6WmBOrB/UUXJ/FPntPt NHsLBm9OzCNp6GnV5L1A8WTmFxBa3ASAZRe2F8ErZ0kQVDuEnce6OoiGut9TdXv5c5PII dzEMP0YOVS8JPnmUM6CHUlWdXGUGQojWQaj2Q+R8Y7VXy5XK59EKZmX8+dn+JUn1J/w/n UOiVobLilh2quUmA78d6Pe5ETTsMWT6weposTL+WLUurXxMtnUUOSk+J49zuoBs4wnQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796401956; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=tHHXOl8C9ryVB41BeAM+Bjk3ahx4ZEVg49m1/9Fvt8Y=; b=x21BRmpEMfHfr8XDBQTTkEJ3MeHjnX06CVgZs37E3oOuxKr8d4nNDFpaLv793biSLu21 tFRWQ2q+wyixSKixR7dE6xtcJVnNFrSeTE/JqElph/H36Q2D5TDb0yPj2Ow7EW4vp7eBo fZviEDPoMJYl278EXpXt/5n1QzRh5999hgzqgYtQv+8LEF65kmkGVVoptGOX2+W6LoY9A RZ/tEiHGAn1j/NeA4BoeXMiiOuF250gj+aMjiKnQ7iypZqA4PbsPkO5BJei/vsUeFEFFC o9trfad/xgKZarPZzsmYQuV83y/fC9SfwlrgGnC2dkkE7AQdCSSjIYbr6yg38SmpxDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CF59zZx6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id B7F0F606A32C; Fri, 4 Dec 2026 16:32:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CF59zZx6 Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id C1A181F000C2; Fri, 4 Dec 2026 16:32:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796401956; bh=tHHXOl8C9ryVB41BeAM+Bjk3ahx4ZEVg49m1/9Fvt8Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=CF59zZx6P1qA9e1N2ZLAI+kmlmyg0oNv4m+NTqhbpL7GkEN9y9zsaKHrmSwbcEWDa Q+XNORs0E4OMIfoduDrLUS/mRP71iPNvOpKu/Gbw7yGWZ3Y4UkiDQgHdCNK+mWtySx XkbYRrGn/7GzcqMxkGxfFGmECnnOKNGNaGEsQoCMWbmyXbphuJzbS6Y8MPUXXb+yxx ac6nQ4KXUHQ21GRrZWVvMwPunrO/fA0SYNLWCrTF1KYNWeJwZNq7yaf+BGWg87OlMq 5RCWi6pjr/3DTPzXJn5F2KnWiHSPZI1NEh3LY6uo6JFRg5KrNlj5X4v/h6Y8LluMVX wEiRbPMwzCHjQ== Date: Fri, 4 Dec 2026 17:29:24 +0100 From: Nicolas Schier To: Erkan Erdem Cc: Nathan Chancellor , Julian Braha , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Bill Wendling , Justin Stitt , llvm@lists.linux.dev Subject: Re: [PATCH v2] kconfig: preserve the final answer when input has no newline Message-ID: Mail-Followup-To: Nicolas Schier , Erkan Erdem , Nathan Chancellor , Julian Braha , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Bill Wendling , Justin Stitt , llvm@lists.linux.dev References: <20260907103739.23212-2-hexvalid@gmail.com> X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260907103739.23212-2-hexvalid@gmail.com> On Mon, Sep 07, 2026 at 01:37:38PM +0300, Erkan Erdem wrote: > 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. > > Add regression tests for string, int and hex answers, with and without > a final newline, in oldaskconfig and oldconfig. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Assisted-by: LLM > Signed-off-by: Erkan Erdem > --- > > Changes in v2, addressing Julian Braha's review: > - Add an in-tree regression test under scripts/kconfig/tests for string, > int and hex answers, with and without a final newline, in oldconfig > and oldaskconfig. The shared test harness is unchanged. > - Submit this fix independently of the checkkconfigsymbols.py change. > - Refresh Cc from scripts/get_maintainer.pl, including the LLVM contacts. > > v1: https://lore.kernel.org/all/20260905123237.40670-1-hexvalid@gmail.com/ > > An AI coding assistant found the issue, prepared the fix and changelog, > and ran the original verification. The assistant also prepared the new > regression test and this v2 revision. > > Validation: > - Built original and fixed conf with Clang on macOS and GCC in an > x86_64 Linux container, using -Wall -Wmissing-prototypes > -Wstrict-prototypes -Werror. > - On both platforms, the original conf fails all six unterminated-input > cases and passes all six newline-terminated controls. > - The fixed conf passes the complete 33-test Kconfig suite on both > platforms, including all 12 new cases. > - This tests the host configuration tool; a complete kernel was not built. > > scripts/kconfig/conf.c | 2 +- > .../kconfig/tests/conf_no_newline/__init__.py | 32 +++++++++++++++++++ > 2 files changed, 33 insertions(+), 1 deletion(-) > create mode 100644 scripts/kconfig/tests/conf_no_newline/__init__.py > > diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c > index fe8ba09b0..46c9ca646 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; What about this instead of the "complex" strcspn(): size_t len = strlen(line); if (line[len-1] == '\n') line[len-1] = 0; > def = line; > } > if (def && sym_set_string_value(sym, def)) > diff --git a/scripts/kconfig/tests/conf_no_newline/__init__.py b/scripts/kconfig/tests/conf_no_newline/__init__.py > new file mode 100644 > index 000000000..0fca696d2 > --- /dev/null > +++ b/scripts/kconfig/tests/conf_no_newline/__init__.py Did you see Julians feedback? Or did I miss v3? Kind regards, Nicolas