🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23384

Re: [PATCH iproute2] names: terminate the name returned by id_to_name()

#23384
From: Hangbin Liu
Date: Fri, 27 Nov 2026 07:05
33 lines
9004 bytes
On Wed, Nov 25, 2026 at 08:47:21AM -0800, Stephen Hemminger wrote:
> strncpy() does not terminate when the source is as long as the limit,
> and the tc class name from tc_cls may be up to NAME_MAX_LEN while the
> caller's buffer is IDNAME_MAX. A name of 256 characters or more filled
> the buffer with no room for the NUL, so the snprintf() that formats it
> read past the end.
> 
> Use strlcpy(), which always terminates.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/names.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/names.c b/lib/names.c
> index 4ecae92b..697942d2 100644
> --- a/lib/names.c
> +++ b/lib/names.c
> @@ -142,7 +142,7 @@ char *id_to_name(struct db_names *db, int id, char *name)
>  		entry = entry->next;
>  
>  	if (entry) {
> -		strncpy(name, entry->name, IDNAME_MAX);
> +		strlcpy(name, entry->name, IDNAME_MAX);
>  		return name;
>  	}
>  
> -- 
> 2.53.0
> 

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <awkrrM2Tu0tveZMv@fedora>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372511-linux-kernel-netdev=dewy.ru
References: <20261125164721.1942828-1-stephen@networkplumber.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372511-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH iproute2] names: terminate the name returned by
 id_to_name()
Date: Fri, 27 Nov 2026 15:05:16 +0800
Organization: Usenet Network
Message-ID: <awkrrM2Tu0tveZMv@fedora>
References: <20261125164721.1942828-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="665293"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:2LSo+Hwe8SQiGESbcNoHYxZZqeE= sha256:i8LMB99yGwPpsSnJmnEps1k7y9IE9gLBb4hWADc1AxE=
	sha1:Z7MlYHY1KY03XHdGQ57q+X7Jyqk= sha256:o8bmkmNsPzrTjUst279POnC2NicDg8auxvHdPsztCsQ=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id D8B92125F13; Fri, 27 Nov 2026 10:05:41 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id yEj2dU-viJOn;
	Fri, 27 Nov 2026 10:05:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372511-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 88409125F11; Fri, 27 Nov 2026 10:05:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id D4E2737279; Fri, 27 Nov 2026 07:05:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1795763128;
	b=hVxSQ1Hsy92YjtCgXPvkgiEuylGfYwcCeyFo/hd/mMHx+S1rnTT0VPeQ68xF+pK5KRmj
	 50x/XIa00kudy2CYF0r7gdRsZXqAwx4uujykGiWAEFM2zakSL1uxM46YznbjuBagxoKjb
	 orq2FXg1hS+4lvJGH1PO1QwlITQZ6pWCgREGRH3vmE0EF+mbxSZ1DIiVP09W/0BQVbySj
	 rtTtzG/XV4xQSn+BXusnTwM+rBonhOuhEC5CqIpJ2OZitKb9Vy7r6XC6Qr5n/0iR8p/+M
	 Hgrsfcm1eReBYRpqHE+BgsAD/388sCBG4G4zno8tP3o16KODLoOw2FlvZmjHKTvbn4A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795763128;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=fFOwbPhYtG2VA+fvtjG+N9SEnNkXpuXFk3FuyEsjnUY=;
	b=07j2z93ec9C7OrYyfKQDHD/jydGp63G8uShuXfVxBOfoZUeyXs2BdiF7KgPruEQvkqb9
	 OXp8iO7nGQVBfyOIoPFZDSykTuny0ndBU5x8k+xPu5fKZAC1SUpQ5qstQCwcOTcKTytpO
	 X8VViT39Brf0W6YE7zTuHM3AwjJRnyj8yB0EYwWruFTDP/iSt8BZ6yfp7BcH9C2Nz9f+L
	 z3T+a3LuJGiuxTqxF1tpQPAyZpM5WdiRFflexUPc55+PhGqu7R6eu68RhANy+7kjQcjLV
	 DPyy/c3cUkWwBo8zmu/mJK+nkNmPgqNmZcVab7NKbDzzI7ZiA6xOX1XEdF6dziQ2eUQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=dGEuhynH;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id ABDC9606A32A;
	Fri, 27 Nov 2026 07:05:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=dGEuhynH
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.56
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795763127;
	b=JTRv9nMqbL/BXazGgEgT6qnShChXanWQuUKIM21npAeT0ifCiKlGaJvr75AlZVuzIM9y
	 EQ6SLH4PNwTC0Dm3DV0c02NJvhKOyVuhSUM0bUfYzDy0JO5CgF1rxAIGoomBsyLCqMcul
	 FRzAtaj1loJlN4o+ASLlw+vQkMwCIuomdMEzCf4JI57JnkUGyRXSXlHMWXD24DPbtJZAv
	 9xGJAFoH6+f2TkSSM9wdJnuGfLNgKIv3JILHU5tPIDHyeBH7ReKC1nmwS9IpFcXj+MhuB
	 b7Gx73TDdsQjcvzKetj+s7vtQQiHpa+x5xy87fIcabTN9OWCI9LP/0lI2fh7lOLaIQw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795763127;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=fFOwbPhYtG2VA+fvtjG+N9SEnNkXpuXFk3FuyEsjnUY=;
	b=narmtruu+kRZgqQQa/B4Srwm5U/5SlBoY4Q3RrNeOD3ihZjKUN287PWTbdKT0HJKEprH
	 0Sqm4p2VALTC67ZNF24L12+2Rg4tNopRhdKG6Hk9GbQSpS+rdjHgfpDZk7t38ChvWhce8
	 5gIcZ2r+IlzJhkNrcwUPJQlG8rRgs1XoaOq1pRJE7Cnix26JaaIPFZRoMMH4ZZ+Kb7/es
	 xpY7k467TtDXHopo5twEu1cfFlNGthFRVnybmqun4SAjYkGdaClZrw35ABpSx3EVO1gWv
	 NUiZT0wjw+WXJxQiH4GjaOTYGIWLjGBC5dhDMJgMUcS5+nuEYhEnL/MeJ0s3dOg5i7Q==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=dGEuhynH;
	arc=none smtp.remote-ip=95.215.58.56
X-Received: from mta1.migadu.com (out-56.mta1.migadu.com [95.215.58.56])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78BFD606A31C
	for <netdev@vger.kernel.org>; Fri, 27 Nov 2026 07:05:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78BFD606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=odMuhZyhTxb63ua+fYRErxMQX4wCePsPK5HbcEK85TY=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1795763124; v=1; x=1796367924;
 b=dGEuhynHzpnjRcWSmhXa2B9DjkK63AGOK7QAk5a+M8KPsAfI1wUCr8iPYZGy9jTjWuKN04ns
 d6+Etnvt87OKdVBfmH3/yawcVAFgDbF0vXj9+Ml0xHqH75G9CpqYAzOjlkR3AnNVQijfvAESnfU
 s/9/3o1QWbgeoRV+9sEWMVt4=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta12.migadu.com with ESMTPS id c4d1fd8a6993fb10;
	Fri, 27 Nov 2026 07:05:24 +0000
X-Mizu-Trace-ID: c4d1fd8a6993fb10
X-Migadu-Flow: FLOW_OUT
X-Cc: netdev@vger.kernel.org, dsahern@kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261125164721.1942828-1-stephen@networkplumber.org>