Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp801216imu; Tue, 11 Dec 2018 07:48:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/UJ9Cpdd3T+6ahA4lGRiACBcoPVW4O1Av1y9BNWG3LUR3OynQ9EQVMfgabowWtGoRH2HxSk X-Received: by 2002:a62:2cf:: with SMTP id 198mr16923962pfc.67.1544543314723; Tue, 11 Dec 2018 07:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543314; cv=none; d=google.com; s=arc-20160816; b=XbqAL64cgfiuyjyGBC0MnSfpsILKO8tkaONW/+UpkUzQndZX51I64H4ly2gfYpm3h8 /EDKR3R6q3UVgWziytoUA+ulE20oUU5+Cyy3gLbLw00qL6uWamhtO5+K3Sh4kJrnISly v3PR2jfRdvt+hzxUX8QxiCSMojzotqpCLWAOgCvEeMRpK2QWqL8TFTqWcA9gFPqfgP23 5qyX8j0wdQAZUJ+ucXCV1hy7J5TQMPY7IBg+iNeSnyHpbh6okuFjKeffCe2NEsS3brM4 jaTiNWDgty1XKMcC2M5lPnkd6zJXazQZbZm4MOIkH1BX7Pocd3pqw9Fr4dOyQKadr2lo 8gzw== 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=gxB5nm7OyS2gSurKv64UWiG6KfnmfKloj5/5Jjq/PpU=; b=D6cDKdzogCkP7QRH+IjnVeUr+FMYjs5C7skHyFPnPUhCORHpYQuPZUfKoAdZ/kBPKd E8XreCaN1DMmDL2fMijwXSZyplw9Cg8EZqeCPRx/ZK/dGGfX7IV1/FLWQiNIhd6FIvgo BgSHQD1WT2mM7kGZcc/rLvKk1z/1YI+ok+HOrE0uP98eL2R+EBpEtvy6uSlUG8jK2Sd7 0/O453GgI4WeUD149cWdsDEjFXI/ai+IwwyHt9MWcVloi0fWcbFKwNNZP7pixg/BvbtY pTkc7ByZZ5n6YD1hcDuyTZrc/7JRnSJrhMggAq22yb4z5jsJB95dm9ZX/efrMZkhhUhe OM4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PpGnOYLC; 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 g12si12156875pgh.368.2018.12.11.07.48.19; Tue, 11 Dec 2018 07:48:34 -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=PpGnOYLC; 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 S1728129AbeLKPpd (ORCPT + 99 others); Tue, 11 Dec 2018 10:45:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:33930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728119AbeLKPpa (ORCPT ); Tue, 11 Dec 2018 10:45:30 -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 45D1F20870; Tue, 11 Dec 2018 15:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543129; bh=TVKLsX38TiclIx/TQqYWCvTNdLMSbQYtQcDN7Uusnk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpGnOYLCN3uu7ew3ZR36Mg314AUBC3BJwuUeYhzR1+RMA2WsDjjYfIXIk1IJJQnzb bVDkp/1cOODM3IDfGCBe0aRWnCNx2tVhp2vzJaN8ylcPmMySU9M9W2j8BOm8sMXt1P 5KAVAgft7N/at4HXG3Qmie6uTRX4v3OSZB/YaVx0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck Subject: [PATCH 4.4 24/91] kobject: Replace strncpy with memcpy Date: Tue, 11 Dec 2018 16:40:43 +0100 Message-Id: <20181211151607.734672744@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 77d2a24b6107bd9b3bf2403a65c1428a9da83dd0 upstream. gcc 8.1.0 complains: lib/kobject.c:128:3: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation] lib/kobject.c: In function 'kobject_get_path': lib/kobject.c:125:13: 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- lib/kobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/lib/kobject.c +++ b/lib/kobject.c @@ -127,7 +127,7 @@ static void fill_kobj_path(struct kobjec int cur = strlen(kobject_name(parent)); /* back up enough to print this name with '/' */ length -= cur; - strncpy(path + length, kobject_name(parent), cur); + memcpy(path + length, kobject_name(parent), cur); *(path + --length) = '/'; }