From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 461AB45EF0;
	Thu, 19 Dec 2024 23:53:34 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id B92914060A;
	Thu, 19 Dec 2024 23:53:11 +0100 (CET)
Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com
 [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 1614A402D0
 for <dev@dpdk.org>; Thu, 19 Dec 2024 23:53:08 +0100 (CET)
Received: by mail-pj1-f44.google.com with SMTP id
 98e67ed59e1d1-2ee51f8c47dso928357a91.1
 for <dev@dpdk.org>; Thu, 19 Dec 2024 14:53:08 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1734648787;
 x=1735253587; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=5XBgPOnMDitzRoPHY2XqxkOl8UQmoTx2OdK79MN1YRQ=;
 b=Jy6Da9mhgTM/1HxK/ttJMY44ZVbeSmeJe1ikJ3ZPlTqYJsmDmMkIFHoG/ulVBTgGr/
 3pWd9ahXbPNVGlbhUA1H6atXQeT+is5THpmMruP8fimrD8ysBg/jxYBvnPco/LpMQlH+
 w/gmiHs5m9ke7+kG8/ge3DGnl8/jzjEO3EcOWl54KwOAS8+OdjWDA8ulzQf6KOyyM19/
 fT2bNkddTv3wGTMtFNysxx/muTaDndlL2sPe3cAN8ebs2hEcLSoLIwEQEbZ5Q7H/KiAr
 2P7VQwU4SUj3pXO/ELkI/yq40EZspFv2TxUG3/gLNNVIlJQtnurf2jOyDtVJpWkDbEei
 gC/w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1734648787; x=1735253587;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=5XBgPOnMDitzRoPHY2XqxkOl8UQmoTx2OdK79MN1YRQ=;
 b=QIMH6ZlhY3u0oOcNKwCqtOjZ1a5J70R8klfvkxDufpOyH/nf80dVh9NoJ+TfWgt5FP
 8o95+fzVBELqkDTm8r4XK9+mPWymNGM1RW0MWdt1xNL9j60mjFfC5GnJ5U7Gz72DVCrx
 pv0QyZvWxgk459uXYnYdBC+BW011Zlm6dMWgnGnA1Z5RkbQp4suh0EJaMZGotb1Mzc3Q
 B9zDCsEnKHVICjTdcOoL0AmnJ+MEZQGC5Ooe9JQlBuyOW5+rwSEs0W9EOqmkSYhm9LnD
 Y3GvCBbdwWdFZsJoHUG2HF1tjRTS+aZpSu+p0hhEEa4pDx4AV4u99n7/bDsSvyKbp2Hz
 mY6Q==
X-Gm-Message-State: AOJu0YzabQsr31s9IxpSnBmez/XsANR2tPT9mVpyrb4ZWTgNPt5aC4pc
 wcy/acoy64bK2grn4CeJm0pybiHgGHXAN7BfLWlig22VdWESfNrjHXsToz6Nv9aSltt9pjUY/he
 vPc8=
X-Gm-Gg: ASbGnctra2JVc5YwK9jVDmNjdzLejMmYhmI+vuPjqKPHGUGGW+zm50vqdetDkrF5z3V
 GOl4bkNauQeuuKqMVR6nSyVYBEEO85NFOyXUiy15+/bCRvicWRLAC9CVUWKhJenikK1CCcK4vSg
 wYGFBa6RZgsuAapCfMM0Bv1+9OqShyxPtmc635RWpoiduvrDckQiBcm60mRwbPcdDn9jASleCuQ
 zuX1Fd82n4NHfJzeYhIE6ss/6fE8i7/1BfzqDC9hPHwVm+/Kio9HSnFmQHBma6jqGxseHeRBc/t
 9Sv/PWiwuCaUMfzROxCy5e9dPsK7VvcigQ==
X-Google-Smtp-Source: AGHT+IEVF5IhsvtccJVUDFcS3/4r9vgm9mGreHVOs16M+i0T5cVS/IJ10nMzj39xqvErk2n0Ahp+xA==
X-Received: by 2002:a17:90b:54c3:b0:2ee:8439:dc8 with SMTP id
 98e67ed59e1d1-2f452ee6374mr1019634a91.34.1734648787354; 
 Thu, 19 Dec 2024 14:53:07 -0800 (PST)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-2f2ed62b30asm3901021a91.12.2024.12.19.14.53.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 19 Dec 2024 14:53:07 -0800 (PST)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
 Maxime Coquelin <maxime.coquelin@redhat.com>,
 Chenbo Xia <chenbox@nvidia.com>
Subject: [PATCH v2 5/5] vhost: use strlcpy instead of strncpy
Date: Thu, 19 Dec 2024 14:49:55 -0800
Message-ID: <20241219225253.782792-6-stephen@networkplumber.org>
X-Mailer: git-send-email 2.45.2
In-Reply-To: <20241219225253.782792-1-stephen@networkplumber.org>
References: <20241218170530.140747-1-stephen@networkplumber.org>
 <20241219225253.782792-1-stephen@networkplumber.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Some tools such as gcc address sanitizer will complain if strncpy
is used to completely fill a string since it will not be null
terminated. Since the previous code forced as null at end,
use strlcpy() to get the same effect.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/vhost/socket.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index d29d15494c..f938189cc2 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -359,8 +359,7 @@ create_unix_socket(struct vhost_user_socket *vsocket)
 
 	memset(un, 0, sizeof(*un));
 	un->sun_family = AF_UNIX;
-	strncpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
-	un->sun_path[sizeof(un->sun_path) - 1] = '\0';
+	strlcpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
 
 	vsocket->socket_fd = fd;
 	return 0;
-- 
2.45.2