From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC6A5232395 for ; Sun, 10 Aug 2025 14:24:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754835892; cv=none; b=WAhvPD1jb3PwWCA/s1eiHt8nH1RS4aP75oHJ319saHi03mo4dL0kqyhzOxDoak0gcQyosqhU8p0AHGuIVUgLnW1qTBY8h0ROqZiIHKGJmayrlG+/VwHAvlsjBVg88QHJ5j83F7cjkUvTgBj9d1FVA8k+yym9+kK4Fcg+h7jRqqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754835892; c=relaxed/simple; bh=DKtYUTZwKfe/xnDN0Q/eysOMuDlr3kISgoRxy7/gk1Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TAPK9waAGeQX+xGyLqd3xlb6XaueEZqUnDmbLP64vlRwyrZoiyN732MIQ0xbnK9030AiuklUMyR3/MlcaIHUb8Eno3lFpbQ5iLHzeJAJsm/YWGmBuQz4rZjb8gCRUMU2MO90WLwi4xGDNwH2/TLBoajj3QDIk3E3mlaEXM4tX6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=j5H5RdXC; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="j5H5RdXC" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1754835878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=n4pmp2kBGyL11OgvKZgasa0Vva47EK/DLMdAgh/XFsY=; b=j5H5RdXCAWRchHzn+mg/WyfpaUoMpgzFGeVIbiUraHhtlasL2GmABZTOhxSLg3LFvmDbQD +rIjgzxZE0k8T4954C95AYhfEBivQ4okS3bwcM1NhYrgdPIBRPjlulk+VzQSCK09ogLzVi 0yj7AQKp3SGDavXmSi3xhCQ8yJOiRp8= From: Thorsten Blum To: Masahiro Yamada , Thorsten Blum , Randy Dunlap , Nicolas Schier , Shankari Anand , "nir.tzachar@gmail.com" , Michal Marek Cc: stable@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kconfig: nconf: NUL-terminate 'line' correctly in fill_window() Date: Sun, 10 Aug 2025 16:22:37 +0200 Message-ID: <20250810142239.120294-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Use 'min(len, x)' as the index instead of just 'len' to NUL-terminate the copied 'line' string at the correct position. Add a newline after the local variable declarations to silence a checkpatch warning. Cc: stable@vger.kernel.org Fixes: 692d97c380c6 ("kconfig: new configuration interface (nconfig)") Signed-off-by: Thorsten Blum --- scripts/kconfig/nconf.gui.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 7206437e784a..ec021ebd2c52 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -175,8 +175,9 @@ void fill_window(WINDOW *win, const char *text) for (i = 0; i < total_lines; i++) { char tmp[x+10]; const char *line = get_line(text, i); - int len = get_line_length(line); - strncpy(tmp, line, min(len, x)); + int len = min(get_line_length(line), x); + + strncpy(tmp, line, len); tmp[len] = '\0'; mvwprintw(win, i, 0, "%s", tmp); } -- 2.50.1