Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp843149imu; Tue, 11 Dec 2018 08:23:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/UloQyp6BIGCTMUDsLCvlVQa1qfWOClutn3YSpDb7EFNuW81a1I5BXVfxb8sgNDPdQuxvPL X-Received: by 2002:a63:26c1:: with SMTP id m184mr14183823pgm.367.1544545419497; Tue, 11 Dec 2018 08:23:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544545419; cv=none; d=google.com; s=arc-20160816; b=ZqyHxJ7fscd+5brrY0hHCJhCasC31ZMzS/igm1k+s4+u1GH8VBHPgBsMH7zcbrjlj7 rcyaRoa2XXpxK4tQ4e1l5OCKeAIW0DzsKKSwRJfEMu5dDuGdV7RWrH282WTYqaNjMueZ nqSUQpCMNGgG3e0PZQDHvX6+mrrv3MhDmktRsW4eTtXfQLplbbiG6aTXPSV+pUJsOVxo iO75I1zDDR2nJL4iTFzptxRdh9/48d1fu+7lSQGWzOjkg6HXmySV2jstWGARL1GV2m7U p8MVkG2LaoslZ53LNBuHmdyTDT8fgQJlaBnyK/AHf45/6I46cArGwIDhc9JjIitVfJpx fXaA== 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=GIYi+DhE91rekzydM368vFtOPZY9aAgKXSxF+KnYKSE=; b=OZciRNNjx3QYqr4Uwr/Tt0L91OZMT1XhzjmXqAe3Byx7zR7Pp5m6V8mPM/2kqPbKle R0yW1KdXDDHKNsummd0x043mahm8OoQvK35S+ce67LfSSqh+GWLgFYLCy96xcoD8yja4 zEZxirGbAww4WF7YZyRF+amH60DfNSyaQwheYHsgcQwwrN+KrPkMAeg6ylhhBgaEeqq0 yI72ribbNrhIE7vfi3TmarAngSHh0AMZFYZbLi0dvfKdc0NqOQgebx9Aekm9Cwce3ZE4 IykC2xxhF0fSSRSnb9WOD2mTj6ZditJlm6fVO4qbhPh5dVoYq+jLEmBu4GS1YuBCxQgH giHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MB2zTuKY; 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 a18si12578665pgj.77.2018.12.11.08.23.24; Tue, 11 Dec 2018 08:23:39 -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=MB2zTuKY; 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 S1727812AbeLKPoS (ORCPT + 99 others); Tue, 11 Dec 2018 10:44:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:60872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727766AbeLKPoQ (ORCPT ); Tue, 11 Dec 2018 10:44:16 -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 BA2E020855; Tue, 11 Dec 2018 15:44:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543056; bh=XFoGy2Px+3c33iyTdV7xQJniQwQPDp1TQ/cvroU8ZcE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MB2zTuKYmfYrr7htGxh1bQMthD3zzVTmLtGg8lvSQ1tiCzKAyoFzhPI7rocK9KmRp mP6IHklRpHL0j7iHldYQjAaw1J39IdpI9Fgk6w1VTcRfrt5Ea1Wyc15emxuNf8QJA2 jmBGkxafRhmitp+F/wFwslokHgenZSaUkYl3AHgM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck Subject: [PATCH 3.18 15/54] kobject: Replace strncpy with memcpy Date: Tue, 11 Dec 2018 16:41:03 +0100 Message-Id: <20181211151546.838702709@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 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) = '/'; }