Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp841547imu; Tue, 11 Dec 2018 08:22:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wwotiuxbi252RrIXp7v/InLsPqGx+rv/fV13Tb0HyvO2a5JW7p57xIxQmTJF7KfS37nwrX X-Received: by 2002:a17:902:e20b:: with SMTP id ce11mr16016698plb.251.1544545339386; Tue, 11 Dec 2018 08:22:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545339; cv=none; d=google.com; s=arc-20160816; b=bR+G1jTraczvfJ2wn8Dj1e4TCmD9QgJDQvfgrba+1DjL0m49GQS+tFWhwX0Q75EfVW nMOrwlWD6RsFn8vr7snXxC/WnIYL99ySV3lT/XTTmtBvM0RxDLcCkXIfx6jQu80UqcSs eBKZWaklESMPx8KcsEXUK0KW7ODsXsmP7N9TL3YBpKU3QFTKgFrrXJTHKc4GlXBjuy/3 1ILdTEYoLV/IxE/3WtoJUWBlIrxsCACT7InZsfBiLzW1XX61Qk5AsCpTB/LRJJ3ST39B ixJpgGxrywXuYeThvcIuY6BjqBlHLa5bh0kEjwB/+eDVtNguv6oN5uFnmncmIHsHR/Y3 MVEA== 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=hZeh0EnkRWf5x3rz+nRrXxqWtTCO1ypjBF1rEsIZNrk=; b=F5Q8/ZwQYFciB7tOjRt9FT2Y2Xg552LsKRDyD3GfnNsYFvMWMAbdZj4n/TEgVlBUcc pFkTX5uPVgERTmnZZefBX9pgEMVlgQ9LowRtbULbQ13OQFqBAxczhY5FkOeduxLGPxgl MzJ9qI7wXBIWo57cPQxIvfLfIbdUyWWTnFe6EHB8md2Jxah0cMIf28Aw/o4N/sovzLlT y4LNQAaILlaUc+DyFi3SZEHyUjLIkDADTt4zc2sEJBmzeGFIPJ7hEhvWB/g7ozGODMce 6DMT2MtuiU6nZLAs09iSSM6YLPSuc5ExOmpDN9VHmaa6Bh4f5tPozfYEyp+mhyIPAdkG 4CTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gSHhi4Fu; 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 q7si13543962pfa.99.2018.12.11.08.22.04; Tue, 11 Dec 2018 08:22:19 -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=gSHhi4Fu; 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 S1728138AbeLKPph (ORCPT + 99 others); Tue, 11 Dec 2018 10:45:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:33998 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727613AbeLKPpf (ORCPT ); Tue, 11 Dec 2018 10:45:35 -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 95314208E7; Tue, 11 Dec 2018 15:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543135; bh=MR52ceTF3CQ2z5/6MOkj4ExVyz9Z6pins38wddcvWmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gSHhi4FuGK66MqobYgoa7Qql5I+nCZPxIlhe/1MYInPu6RIxRpZW8ARsuwhv/7t10 A2/SwrjFDBV2R/cb8vTOLQXYpBVHSdgk5VxLtpxms/YywYbH1rjK7k1biTQfVymcdh TlpzbFmxBZJOBrWL4h6g6kF5akL6yFlbti4+XnRo= 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.4 26/91] kernfs: Replace strncpy with memcpy Date: Tue, 11 Dec 2018 16:40:45 +0100 Message-Id: <20181211151607.925552714@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151606.026852373@linuxfoundation.org> References: <20181211151606.026852373@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.4-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] = '/';