Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10786161imu; Thu, 6 Dec 2018 06:48:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/UVRefSRSY8LQC+qRO98gRYjca3cefrbh4uy43rQI7LQ1BvYl/F0yfdZuH7SyweaIppejjd X-Received: by 2002:a17:902:280b:: with SMTP id e11mr28684731plb.269.1544107722496; Thu, 06 Dec 2018 06:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544107722; cv=none; d=google.com; s=arc-20160816; b=V6eIQGlxjwJ/lbsxI3WE9y2WkBZlmke5qBLJ3ArCyK/RYvRvddgoEW+GHAOJkJggcD P/XcWbhZ86FDzZtPV+8PTo/cg/jWyz795l3aaGQt9hZ+ryEoyEjP5+bqFJYol6+Dz0Yd pN/eQcB/W028u/ldIHl8HmSdReB2ps0KTfQITUyf8cnL195FZ/puu6ToHs21qydxDgz4 0IUlmiTZ1B7sejvSdlWGsU35g3/uJlhEoMu+8vcn+sjmdLPWzWRokmBVl8K3YkdDs3un SA3EYRGRzrHlpOYSMUhydKY9RsDy74KU024jk53q0hIyLpZ9RDhSM4jaCzwZwDcteM+n lOlQ== 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=YkyQMaoJqQezqJP7libn/PRxA3IbiLQFbEGW/OGMEBs=; b=UzZLlhCvBbXOAVEtHu2OmxH3kWPvR9ToZm8BbNCjAJ+kuUxoqv76gFRzL+SI5aNRuh 9xC0xLAM5JmNBXOcE14sFkDmQSkOpLNpVgv2NZrzea08r5ffA5fMMfAjDQFIzoagqM4D BenWlqmgrQ2zVHhAmCpziObve6kPT36dG7KODnQzxcg/zypbuKZldrwtRW9/thuEvm/7 /XTCiEyj9+iP/v7PCGhB8LffyitDyDRI5DS5Jdo+vxl5L55C6LxT59pBU1g28VtdIP1I O/B2BbwmzBakLJnn2DnZ8okbalVu6AlinApf41dl8NS++Jq8sxK269UuXc62F4BsQbTN /ZDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kasEts0w; 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 i13si425901pgc.41.2018.12.06.06.48.26; Thu, 06 Dec 2018 06:48:42 -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=kasEts0w; 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 S1731060AbeLFOpZ (ORCPT + 99 others); Thu, 6 Dec 2018 09:45:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:50046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731039AbeLFOpS (ORCPT ); Thu, 6 Dec 2018 09:45:18 -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 99EA820661; Thu, 6 Dec 2018 14:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544107518; bh=SxmSdbJfkit948WoCRofnAJqsJXA8wxuz4dV6ql06Cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kasEts0wWkFL7aeDsgxoEmMyuDhSY5zKG29JrJg6Kt/GNsPmixcPJhN28LTw6TxTS ZQNpQYjEvZmWrMI9fumn1neuD33HeEoOA1lmOkpVqJ1jDtdyr7Dc3Wcv4vJr8N0A6r LYNUgRuFL1JtBZRs3jnkejQS6UZD4Mu39jVnS9U4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck Subject: [PATCH 4.9 004/101] kobject: Replace strncpy with memcpy Date: Thu, 6 Dec 2018 15:38:03 +0100 Message-Id: <20181206143011.869256388@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 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) = '/'; }