From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 AA9E02236F4 for ; Wed, 16 Apr 2025 19:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744830634; cv=none; b=dpChndSyrzQclJEGRNKLCXezcOD797b09pltua47CC/TTK7J+cOd+gmMoYv8nh6YTkce+9nye87+XZ+DrvPx0nHrzG+z4QX3fW3M96cZyiJCMUH0gWgruGeWdNAXbqz2gcJpKcAnKE3QcvDYGSte03cwH5s4gpgsnkjAoncAFtk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744830634; c=relaxed/simple; bh=NYcXxrwtogTaNVEDhGFmHHFJqW4cwC8+ZiQeJ7XxKfc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mDWcA9++t4RL6dGUqwC6aFaHJ8b9OEZHb8JFhzCxOBWSR+r4OQGB92EYV2JcAxJZNOHluIqM+psOsOAqV2oaFjfBu1iH9a3MNbyAFnW3IgQGaFw3ZaAPUA5BoPKMChnyMFcgT6/l/Q5gqGUJ/q1eaQsxacRUbqokVBzVDWLFkhM= 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=FTLN0vhH; arc=none smtp.client-ip=95.215.58.178 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="FTLN0vhH" 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=1744830620; 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=ah8gXRejPfDI4sv7sqjLt/LNTQ/T0TzBT0ooaVXKL8c=; b=FTLN0vhHYwuWObPszCflRy8pJJ3dCNL0xSurgNG/cX0OpdICaaiEHVtv/ogsMjk3i76nbu Dx60Gbrwp1fkKy+tlDthZXn4g8/k6XU5EyE4NMEQIH3l5J3pUAUv9HedCosrkFbNNa9NwZ vqoj8iWDBaTPuZHZz5c7Xn6SMGqtumE= From: Thorsten Blum To: Dinh Nguyen , Thorsten Blum Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] nios2: Replace strcpy() with strscpy() and simplify setup_cpuinfo() Date: Wed, 16 Apr 2025 21:09:07 +0200 Message-ID: <20250416190908.15263-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT strcpy() is deprecated; use strscpy() instead. Since the destination buffer has a fixed length, strscpy() automatically determines its size using sizeof() when the size argument is omitted. This makes the explicit size argument unnecessary - remove it. Now, combine both if-else branches using strscpy() and the same buffer into a single statement to simplify the code. No functional changes intended. Link: https://github.com/KSPP/linux/issues/88 Cc: linux-hardening@vger.kernel.org Signed-off-by: Thorsten Blum --- arch/nios2/kernel/cpuinfo.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c index 7b1e8f9128e9..55882feb6249 100644 --- a/arch/nios2/kernel/cpuinfo.c +++ b/arch/nios2/kernel/cpuinfo.c @@ -46,10 +46,7 @@ void __init setup_cpuinfo(void) cpuinfo.cpu_clock_freq = fcpu(cpu, "clock-frequency"); str = of_get_property(cpu, "altr,implementation", &len); - if (str) - strscpy(cpuinfo.cpu_impl, str, sizeof(cpuinfo.cpu_impl)); - else - strcpy(cpuinfo.cpu_impl, ""); + strscpy(cpuinfo.cpu_impl, str ?: ""); cpuinfo.has_div = of_property_read_bool(cpu, "altr,has-div"); cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul"); -- 2.49.0