Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10798018imu; Thu, 6 Dec 2018 07:00:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/W9oq2xDkFJfa9DBQSm3No7JaV2UGBtebOPoEIWMqKkvI/ONspJDUrsW5Qp/tRprhDVbaM3 X-Received: by 2002:a65:530c:: with SMTP id m12mr23635366pgq.224.1544108428527; Thu, 06 Dec 2018 07:00:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544108428; cv=none; d=google.com; s=arc-20160816; b=aIpk+/lKixIMaV2fjdL6ujdeSOp9FoVslAHo+ezQtKKcIdhhZ/MNVi+nBkAF3WHRy7 eqfpLralFYIh5GDI8DWbUWnyvloBB5x4G3Zgi1hnbzbbypUVpU6ZYGpiqLcbdZHjKw2U xU4df+A7NlVncq0ykhJ1r0Lpf4Xvd54LTFfh0IRMWN+Ybzhlz2wGm5EhFHDt6cXpueHD 36WTeWHMJvflgNNOR39CE+6JPSc3X0yklAvP3OrC9zAo/xZxsn0ziViSXJgXGbbaiuPo 1nUBgJOiY4/kQoJg7vqwJaeB3wO4SuVIbJEcbDraqWw/EbUWF5h1VOOzdb61Dj/0ZslS POVg== 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=L/t8F59dz/bm151FidSAiy0jRSgowkNnFsNgMcq9nRA=; b=tHBKjsZtaqCT2i3EnMlLErwp19RQMSRI6bNQ3Iychu/RKSoNnNrpNmXz+b9BssXNCt VnP8Qwzn7WLMhqAhka2OEYLnPiOBOW7pY5X/12G3oOzUpHJs+g9oytYz7UDOj+xaDj5m KRoFjhWBiL6MFNOyzOlN6cnWcRuGNenHmkC3rrzSsJXksuGkPPkjGYh5PpNToW6L4/Jr Zs+amXnnntCHatG02Val6IqUGUJu56a+2aqqAY4YF7X21M6ydOleE6yX5OjMagRY/4I2 aaX27p4D1lVmWwVK63i51DoI92j48BepAKswMcCSiSBCbV5JWsFFIKPI6c2qLyHnAKxu xfdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Y+oa8cs8; 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 r11si365174pgg.327.2018.12.06.07.00.11; Thu, 06 Dec 2018 07:00:28 -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=Y+oa8cs8; 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 S1730441AbeLFOmR (ORCPT + 99 others); Thu, 6 Dec 2018 09:42:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:46516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730429AbeLFOmN (ORCPT ); Thu, 6 Dec 2018 09:42:13 -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 8B53320661; Thu, 6 Dec 2018 14:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107333; bh=QXbRNwE0aO431n0veUCJbhIyQ0ArDp77sjkquvaDkIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+oa8cs8FR7+bw16PY862Y+ccEU48PN29eKaaGb4plphT/gbysjZNIr5OAl9/jT3R nOgc8+vIXyCqfXz9r3MBy9bI/V+jYdDlbmVBfwJ4UuZe5gmLB/qYoAB83cpRDlKm9K Tvtngqy0G/srQ2hpOqyXnlbs9FxV4cL2ElXXnbYY= 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.14 07/55] kernfs: Replace strncpy with memcpy Date: Thu, 6 Dec 2018 15:38:41 +0100 Message-Id: <20181206143002.137626305@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206143001.749982936@linuxfoundation.org> References: <20181206143001.749982936@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.14-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] = '/';