From nobody Mon Dec 1 22:35:43 2025 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 BB1DE320CA3 for ; Wed, 26 Nov 2025 11:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764155672; cv=none; b=hdeHM4iWt5n8i31BJbe6P+b4mMo0ns2bd4iTNAUBmpBExyhfy1x/Jk5QBxAuCLX8dv0udKySSDNerEzKs9uSiF5u/4XGDfRgFtYKibXrq87pBnRlgOVA8daZS+45mp8gKxElF+K7kfSw+lmhtovdG+Y6/HCgB1lCfNb0U9+E3HY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764155672; c=relaxed/simple; bh=+5prDWlD7lNvY3hLar9kp0MOEBAmRXacq+FAOaruLu0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Nf7he56xHr2lwcYp99Uau3Tsy/OJ9BqGWOP/AgIvUaVHhahp4kzt02RR/tGZX2aUTRxDuQlc49CMB6Mcr2opixYy0z0zklU40KJFrlu9RnBpk9/FvTpdVyJOHefrGvWwYQH5R9a4RAVbqZyqnECPYb7JxdWVSdv7MLuyQtfp3VE= 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=NeX7qZz4; arc=none smtp.client-ip=91.218.175.172 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="NeX7qZz4" 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=1764155656; 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=r3yB1s+BNk75F2/5SJHK9QkN8gG67r1xL/kmC4ebo9I=; b=NeX7qZz4M3BPj3zPu/OVFgMYhQbqe38ndu/9VJfZacNTfzPuET5r08CsnjXHd6wxogBMDh Ch8qjRFNlR+5p/Yn+OuGG8SgFNOMnunqjz44dwmo0q/bNLBNU4MPq9lK0yChfIZqW+UGNJ FovU8L9tNCEh7ChbQ5fZfOisEIy7s8o= From: Thorsten Blum To: "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: Thorsten Blum , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: ipconfig: Replace strncpy with strscpy_pad in ic_proto_name Date: Wed, 26 Nov 2025 12:13:58 +0100 Message-ID: <20251126111358.64846-1-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" strncpy() is deprecated [1] for NUL-terminated destination buffers since it does not guarantee NUL termination. Replace it with strscpy_pad() to ensure NUL termination of the destination buffer while retaining the NUL-padding behavior of strncpy(). Even though the identifier buffer has 252 usable bytes, strncpy() intentionally copied only 251 bytes into the zero-initialized buffer, implicitly relying on the last byte to act as the terminator. Switching to strscpy_pad() removes the need for this trick and avoids using magic numbers. The source string is also NUL-terminated and satisfies the __must_be_cstr() requirement of strscpy_pad(). Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncp= y-on-nul-terminated-strings [1] Signed-off-by: Thorsten Blum --- net/ipv4/ipconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 22a7889876c1..27cc6f8070b7 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -1690,7 +1690,8 @@ static int __init ic_proto_name(char *name) *v =3D 0; if (kstrtou8(client_id, 0, dhcp_client_identifier)) pr_debug("DHCP: Invalid client identifier type\n"); - strncpy(dhcp_client_identifier + 1, v + 1, 251); + strscpy_pad(dhcp_client_identifier + 1, v + 1, + sizeof(dhcp_client_identifier) - 1); *v =3D ','; } return 1; --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4