From patchwork Mon Apr 22 16:39:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10911285 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CC5E14DB for ; Mon, 22 Apr 2019 17:03:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFF4C285D9 for ; Mon, 22 Apr 2019 17:03:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E31A3285B3; Mon, 22 Apr 2019 17:03:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BBED285B3 for ; Mon, 22 Apr 2019 17:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727428AbfDVRD1 (ORCPT ); Mon, 22 Apr 2019 13:03:27 -0400 Received: from gateway23.websitewelcome.com ([192.185.50.141]:40452 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfDVRD1 (ORCPT ); Mon, 22 Apr 2019 13:03:27 -0400 X-Greylist: delayed 1430 seconds by postgrey-1.27 at vger.kernel.org; Mon, 22 Apr 2019 13:03:26 EDT Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway23.websitewelcome.com (Postfix) with ESMTP id F23FE5B37 for ; Mon, 22 Apr 2019 11:39:35 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id IbyhhJSzlYTGMIbyhhPtsa; Mon, 22 Apr 2019 11:39:35 -0500 X-Authority-Reason: nr=8 Received: from [189.250.104.103] (port=39364 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1hIbyh-001iky-5S; Mon, 22 Apr 2019 11:39:35 -0500 Date: Mon, 22 Apr 2019 11:39:34 -0500 From: "Gustavo A. R. Silva" To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH] ACPI: event: replace strcpy() by strscpy() Message-ID: <20190422163934.GA2636@embeddedor> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.104.103 X-Source-L: No X-Exim-ID: 1hIbyh-001iky-5S X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.104.103]:39364 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 22 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The strcpy() function is being deprecated. Replace it by the safer strscpy() and fix the following Coverity warnings: "You might overrun the 15-character fixed-size string event->bus_id by copying bus_id without checking the length." "You might overrun the 20-character fixed-size string event->device_class by copying device_class without checking the length." Addresses-Coverity-ID: 139001 ("Copy into fixed size buffer") Signed-off-by: Gustavo A. R. Silva --- drivers/acpi/event.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c index 5a127f3f2d5c..47f21599f2ab 100644 --- a/drivers/acpi/event.c +++ b/drivers/acpi/event.c @@ -131,8 +131,8 @@ int acpi_bus_generate_netlink_event(const char *device_class, event = nla_data(attr); memset(event, 0, sizeof(struct acpi_genl_event)); - strcpy(event->device_class, device_class); - strcpy(event->bus_id, bus_id); + strscpy(event->device_class, device_class, sizeof(event->device_class)); + strscpy(event->bus_id, bus_id, sizeof(event->bus_id)); event->type = type; event->data = data;