From patchwork Fri Jul 13 01:26:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dominique Martinet X-Patchwork-Id: 10522525 X-Patchwork-Delegate: shuah@kernel.org 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 E3199601C2 for ; Fri, 13 Jul 2018 01:33:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D522729813 for ; Fri, 13 Jul 2018 01:33:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C991229A37; Fri, 13 Jul 2018 01:33:17 +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 8A89129A16 for ; Fri, 13 Jul 2018 01:33:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387966AbeGMBp1 (ORCPT ); Thu, 12 Jul 2018 21:45:27 -0400 Received: from nautica.notk.org ([91.121.71.147]:44826 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387956AbeGMBp1 (ORCPT ); Thu, 12 Jul 2018 21:45:27 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 00C3DC029; Fri, 13 Jul 2018 03:26:10 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Thomas Renninger , Shuah Khan , Colin Ian King , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/18] cpupower: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:26:09 +0200 Message-Id: <1531445169-19912-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 tools/power/cpupower/bench/parse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c index 9ba8a44ad2a7..1566b89989b2 100644 --- a/tools/power/cpupower/bench/parse.c +++ b/tools/power/cpupower/bench/parse.c @@ -221,9 +221,8 @@ int prepare_config(const char *path, struct config *config) sscanf(val, "%u", &config->cpu); else if (strcmp("governor", opt) == 0) { - strncpy(config->governor, val, + strlcpy(config->governor, val, sizeof(config->governor)); - config->governor[sizeof(config->governor) - 1] = '\0'; } else if (strcmp("priority", opt) == 0) {