Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp912764rwb; Thu, 18 Aug 2022 14:47:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR6PYoiPaagaZl/OBE1cXjC03UDKiJtFMGFRDGaVAE+C1YCMqWExgOi5J8SYGUoIo/dnSbRG X-Received: by 2002:a17:902:7402:b0:172:9207:380d with SMTP id g2-20020a170902740200b001729207380dmr4363643pll.124.1660859224704; Thu, 18 Aug 2022 14:47:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660859224; cv=none; d=google.com; s=arc-20160816; b=EpzoIquRpiA/aBx5nP9CNSbrHpJoUb4y0bIYL9NUZ/IwnVdMreexGb4/1WyqIKqT9p GA2UiuGLVpTlm9F16ITFjoWqNaHkMSBMRpN54eNQOrJybpbnD/KhkGFcgMRbWiq+Ehc1 rX5Hm1zaIPNFKMEgaLW7GmqzcvSBp67j+0w0W0wlceMi9f+9Acgqjx5WienslsEzP2AB d839nOX9RX6HdnBwHkrYMaSSBrv7Ugg9s6XBoesRL5vyBa+9oR1/a7tre8oazyh1Bb9Z AJHvnTmNqB/SN77B1Z/N/AHXVctdo+5YUlUVXYoDglWI298Lh0p+Vo6ZliGAm0Hme13J ca5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rCG0ydBBdG5Xbp//cYX/nB9q4UyEZ/zTwBUEAtNwtA8=; b=OrF/qT9nldygCZuW41ueYZlFyURRRaOdpZBdMIlPJzRtiZKOOh4ipIJsV2ssPSDjHb Dr4B1x4xZTpduNw8lBJ8jwjevbVBIwut7R8NpcR/V3fZcuK3GR2EqSqIfqx1u7kcxvDL +afxeu465NqsbSyQplLjxzYXZL3wtwG6NdvUHtBnkigV77P8dXt+31RXb6aJupOj8/6w UH/wGRQ2f9K9WrA6pYLWsaY8tJ/XkQuaUKIkcrzlaP22RXZZtMBaB9g+TC9SHxl0qn0V qTCeFchktImFKrUSe4PAMKkhOCj7M7xAGYsREaWHie6TMZWWUTXKIyGEqAG2xNkuUXvU oNOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=xyHxyOFp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a056a00218b00b0052e3d468e9esi2529131pfi.369.2022.08.18.14.46.53; Thu, 18 Aug 2022 14:47:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=xyHxyOFp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346706AbiHRVKW (ORCPT + 99 others); Thu, 18 Aug 2022 17:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346594AbiHRVJq (ORCPT ); Thu, 18 Aug 2022 17:09:46 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EFE2D86D0 for ; Thu, 18 Aug 2022 14:04:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=9/ea9VxVWR0AeS flWZ3qtYaxvrG4JVxZl/dPiyOWJ0A=; b=xyHxyOFp3WwiViEpV8MAS3PVZ+2Cup y6xMkijDO3tLMxXM9/Irwbht90R1If6zslnmdhQanqEw25bUv5gtGz2gqS/ms3Rx NCueTKMW6QB+Yy3E5O6AxwPN8BErW2KfEKFfyryJn9BfXQNZGkd+8/iefDD1qTqo v/v2HRVdGMuqY= Received: (qmail 3962158 invoked from network); 18 Aug 2022 23:01:35 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:01:35 +0200 X-UD-Smtp-Session: l3s3148p1@O9VpSYrmu9Iucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH 11/14] cifs: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:20 +0200 Message-Id: <20220818210123.7637-11-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> References: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang --- fs/cifs/cifsroot.c | 2 +- fs/cifs/connect.c | 2 +- fs/cifs/smb2pdu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c index 9e91a5a40aae..56ec1b233f52 100644 --- a/fs/cifs/cifsroot.c +++ b/fs/cifs/cifsroot.c @@ -59,7 +59,7 @@ static int __init cifs_root_setup(char *line) pr_err("Root-CIFS: UNC path too long\n"); return 1; } - strlcpy(root_dev, line, len); + strscpy(root_dev, line, len); srvaddr = parse_srvaddr(&line[2], s); if (*s) { int n = snprintf(root_opts, diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 9111c025bcb8..3da5da9f16b0 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -3994,7 +3994,7 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses, } bcc_ptr += length + 1; bytes_left -= (length + 1); - strlcpy(tcon->treeName, tree, sizeof(tcon->treeName)); + strscpy(tcon->treeName, tree, sizeof(tcon->treeName)); /* mostly informational -- no need to fail on error here */ kfree(tcon->nativeFileSystem); diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 9b31ea946d45..9958b5f1c12f 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1928,7 +1928,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, tcon->capabilities = rsp->Capabilities; /* we keep caps little endian */ tcon->maximal_access = le32_to_cpu(rsp->MaximalAccess); tcon->tid = le32_to_cpu(rsp->hdr.Id.SyncId.TreeId); - strlcpy(tcon->treeName, tree, sizeof(tcon->treeName)); + strscpy(tcon->treeName, tree, sizeof(tcon->treeName)); if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) && ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0)) -- 2.35.1