From patchwork Fri Jul 13 01:25:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 10522513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E6F9601C2 for ; Fri, 13 Jul 2018 01:33:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 309CE29A2A for ; Fri, 13 Jul 2018 01:33:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24D5A29A3E; Fri, 13 Jul 2018 01:33:14 +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=unavailable 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 DD07729A33 for ; Fri, 13 Jul 2018 01:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387942AbeGMBp0 (ORCPT ); Thu, 12 Jul 2018 21:45:26 -0400 Received: from nautica.notk.org ([91.121.71.147]:44814 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387918AbeGMBpZ (ORCPT ); Thu, 12 Jul 2018 21:45:25 -0400 X-Greylist: delayed 439 seconds by postgrey-1.27 at vger.kernel.org; Thu, 12 Jul 2018 21:45:25 EDT Received: by nautica.notk.org (Postfix, from userid 1001) id C30DBC026; Fri, 13 Jul 2018 03:25:54 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/18] test_power: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:25:53 +0200 Message-Id: <1531445153-19647-1-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> References: <1531444483-17338-1-git-send-email-asmadeus@codewreck.org> To: unlisted-recipients:; (no To-header on input) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet --- Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the first patch of the serie) for the motivation behind this patch drivers/power/supply/test_power.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c index 57246cdbd042..64adf630f64f 100644 --- a/drivers/power/supply/test_power.c +++ b/drivers/power/supply/test_power.c @@ -297,8 +297,7 @@ static int map_get_value(struct battery_property_map *map, const char *key, char buf[MAX_KEYLENGTH]; int cr; - strncpy(buf, key, MAX_KEYLENGTH); - buf[MAX_KEYLENGTH-1] = '\0'; + strlcpy(buf, key, MAX_KEYLENGTH); cr = strnlen(buf, MAX_KEYLENGTH) - 1; if (cr < 0)