Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp846120imu; Tue, 11 Dec 2018 08:26:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/XJeS+c4qNUGJuaHlXSTWSOSURfJJP65IJO8DkN6Qe3JwdvjImawpihuTf0zLKV+6NxsmrP X-Received: by 2002:a62:2fc3:: with SMTP id v186mr17059722pfv.82.1544545592333; Tue, 11 Dec 2018 08:26:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545592; cv=none; d=google.com; s=arc-20160816; b=aBigTxrUvmp9crrDxbzgiKx0TnbcILR30NrWiUiOrZ//JxEEF2ZAPPYb1VH8DCDAjD YVvQiQewA15QSk8i6oVFyDimVqC39higLFFUBrv29oPFRZUHsaGMTZWdyIYavRt6ROfS sylcqfFEMRHGP1RDMGteIWc4wNrW7XRThCvkREbvly1L1f9/iP9I8EGzGigdUMMLm6Zd TZ5lqxv/AdjxA2kH65IdTmp5oSGp/uAHeTGxDjP/CuftKgCeyp3kPzYGiDubpAX5tvUG bD3owUbG0QlKBt1CoeubAgMyB9qbVGOp2i/P2FRLvxO8IB4fPVT23PUwzkv40BwPBa3W 3ekw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7+0TbgyK2/QomxboWMEpH8wnAlY0MzHHUCXclIZRH4A=; b=hT/N8RQeIukIsYSFYEh99aYKi3rHFI6VFTzj5fVeMQrn2wAsud9LE3iTEntOgdeDOK EgHvrCQhRKJIYvW5o14meyEfvHBajt5vV94z9k8wGIPfi/GBAS/0Y4D8Ii3E4/yc5sZK FtcBlP1A9xLTWi9FeeTGiha06kbvvDHejSH7XZ5P92pcyU8BnpJb3yW08Oux+MYYXt/q NuY54KXJDcffeMM9Q4T77hha0RG9MO/2C0eCtpsNe1IVqV6l8YeX7YLf1EEjQaW/plVy 5rk+FXxpEgBsBvCoNXLg0iH/SpZ83IZlbhTEt9vLHfF5C4RqljlgGHFZAmMRQX4tqLzd oVUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kt6guhFx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn20si12659297plb.98.2018.12.11.08.26.17; Tue, 11 Dec 2018 08:26:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kt6guhFx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727350AbeLKPmv (ORCPT + 99 others); Tue, 11 Dec 2018 10:42:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:59226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727341AbeLKPmt (ORCPT ); Tue, 11 Dec 2018 10:42:49 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4DCE420870; Tue, 11 Dec 2018 15:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544542968; bh=ged9Gv3SDWxAtzQMGLbjKOP3hxHX+H7arg2rD7vlsCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kt6guhFxvmSiCSIOtxUWGAtqTAaGFJH00cJli+ZZkQvaYjO2S660EGLnqLzNP0RoL cqQ0rm8DjtMMT5MFr1UBfPahgviABmMYCDhkWEeZNZSLCVnEc00QNqluMkQwu66X06 bvsKzVaLIAAkvUmVjB+rZ/JCXTkdnJlAjc9PMIO0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Tejun Heo Subject: [PATCH 3.18 17/54] kernfs: Replace strncpy with memcpy Date: Tue, 11 Dec 2018 16:41:05 +0100 Message-Id: <20181211151546.944395296@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151546.010073210@linuxfoundation.org> References: <20181211151546.010073210@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck commit 166126c1e54d927c2e8efa2702d420e0ce301fd9 upstream. gcc 8.1.0 complains: fs/kernfs/symlink.c:91:3: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length fs/kernfs/symlink.c: In function 'kernfs_iop_get_link': fs/kernfs/symlink.c:88:14: note: length computed here Using strncpy() is indeed less than perfect since the length of data to be copied has already been determined with strlen(). Replace strncpy() with memcpy() to address the warning and optimize the code a little. Signed-off-by: Guenter Roeck Acked-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- fs/kernfs/symlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/kernfs/symlink.c +++ b/fs/kernfs/symlink.c @@ -88,7 +88,7 @@ static int kernfs_get_target_path(struct int slen = strlen(kn->name); len -= slen; - strncpy(s + len, kn->name, slen); + memcpy(s + len, kn->name, slen); if (len) s[--len] = '/';