Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10786380imu; Thu, 6 Dec 2018 06:48:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/WUiDLfr7koAaSyymNVrIEX/sCUYzqlC9qb+XhoIG+wPljZggwVzZ64GF9xn3pdYivevVQ+ X-Received: by 2002:a63:6445:: with SMTP id y66mr25021391pgb.250.1544107734954; Thu, 06 Dec 2018 06:48:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107734; cv=none; d=google.com; s=arc-20160816; b=n+iJ+tgujxkyDflaKB0/pA7RckAkgRaJqlyuZ2YMpe7ZBe3Kc+E06nYOqYGe8a8KP/ fWdPeGPf1M4XlilgTCPmgLjF2Xj0SEdnjhp9w2q2onrDRiJRNxdoUrge11ujHHZiT3x+ EZB1sv5xk6wxsQUu3pPbXfOEiqAOkbeQy+gqWqQxY6BY0h1ZleYP8I6jvanIjvTLC9Q4 FolfuxVPnn4xabUkJZM4Aj1RXm3PGQtquUrjqccTRszPDGZp1t/gMvefa+NBG1zfjjok lMsS0s6GtFjxc8M6/vTVRh9FmhgAxtNEsgbEaRhE6W1CSpmfs5lGd2CaohEPsseDhBNU 117w== 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=YPWjqBpPPY8qG7mzkASi32r/tKwHTNTFEGgI1af9GqY=; b=G6RR9BrInmvUTK0mVcH9byxec+ARei3UlvSx91WDH8M/9EzW8hl8OeUuK3KxyRSXug wOEzr1NWZMnP+wnxoY0sd5MVBJ5ZIz1+n2Bb/xVJ3gagbzoDGZRH4twDFD70z6mfU0lr FiehzFk9QpiMLcxRmTUUJjBuRRZuq/h7aP5qij3U+m4Ei6vUey7Hr8koyNXbBlC2sz1E fUZyi5cRrkJiIFidqruQHYqLfuwaSHZTEShpn6eCfK1g2wvWPNcFEFvQZEexR/81Ymar kWk5v28gZIYkTcn37/OG/m8WQsIn6dSeEdgE0PxVS61hzIhxUV8h2K//Zd93WrGvr8An XTVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mQUX6gzz; 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 r39si391084pld.434.2018.12.06.06.48.38; Thu, 06 Dec 2018 06:48:54 -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=mQUX6gzz; 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 S1731073AbeLFOp0 (ORCPT + 99 others); Thu, 6 Dec 2018 09:45:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:50110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731049AbeLFOpX (ORCPT ); Thu, 6 Dec 2018 09:45:23 -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 DF2962082B; Thu, 6 Dec 2018 14:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107523; bh=4cInqkkOLKGeSAcTtKyxDrsWh10+PP4rrIWYlcL2xK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQUX6gzzSxoeFiiyfQMt6iHZXRP3NkF08SAH4a0qZZYMoABfInHkWKwyvwi9NfzFm DWepVFthbHOTT0hwv23z1zfOFElgFGt5YFp0sqhtAn2QWULhwhT4L2Xu2nMay1A7MK vmDEBEGOPaO28KDJupyTJls6or50MQXmEos/hhVY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Tejun Heo Subject: [PATCH 4.9 006/101] kernfs: Replace strncpy with memcpy Date: Thu, 6 Dec 2018 15:38:05 +0100 Message-Id: <20181206143011.974644275@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143011.174892052@linuxfoundation.org> References: <20181206143011.174892052@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 4.9-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] = '/';