Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp242223imm; Thu, 12 Jul 2018 18:27:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeMeibXpnap6KE2pXPZsEYhd3gze240FhMnB2zZqI14gy2G/UPLG3zGPbUpk8aHz7RRGUSM X-Received: by 2002:a63:b605:: with SMTP id j5-v6mr4185203pgf.437.1531445275571; Thu, 12 Jul 2018 18:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531445275; cv=none; d=google.com; s=arc-20160816; b=Wj/seu3fR398yZFbdnr3iODNHlEbpB7Md8HJ7nvR2M8oIdNt1FobWxfDowN3ce5Pgn vrn98I4aLLZ/vf24GqqpzP2JSJUTtLv5aNbQdrmmJ7KuWoEm2jgH/ALiOrx5HcXI7pZA JAyhYhwFeIiIatiaBmrl3Emsp4OTk6rCNWZskkpaJ96zbVrvALsqarChNwQf42Q9yUOw roj6CXYkGEmBvNgBbOJ9x1tmvIBTfsEgzKkF1E5gwATdhwxf+BW7M9rs/4dXjhEb/HOx 4dtI53D6pPSGkqEqLpTg4ypM/DFxo7KVz8yhwlFhA6n2uRbOiJ4ElNKx/9btJ0Vt6giD IXSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:arc-authentication-results; bh=7wKs3HDzVnw6IFhKoloxa18w4zO44ViEkgXgGXEU44o=; b=O64opLowGQCEhvwngF8pM2MtgKP52zGP9aFdNwnCa+vCfDMDCcGyzQuYBAQrTX8e9e sp6Hl6IRlSfbu900ognh4EPkYhsQhH7nyoVf6FwnGQ8xzZfM3FAXe2ey4BYKfgxbkE4V LOMeZza2rPYvNsfxbSjx+1f1vPyaLy6en1T8twHKmQNajatZ4jZOXg2XCc6jqHb9MJX/ TXL6Kh1qoUaCuEZXSf9gaJkXl8NvHOqwEwgdLs8EOr4DeUdyaPK03pO5+m5XtBcmqIL9 nGpF9MDNZdySp1lK8jaEg3VGCH1yfYIhIgvRzrJaAMCa01CwD+5ZpGAMYx+CFiMIny4s rxEQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p14-v6si13448446pfk.275.2018.07.12.18.27.40; Thu, 12 Jul 2018 18:27:55 -0700 (PDT) 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; 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 S2388187AbeGMBiU (ORCPT + 99 others); Thu, 12 Jul 2018 21:38:20 -0400 Received: from nautica.notk.org ([91.121.71.147]:43057 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387896AbeGMBiU (ORCPT ); Thu, 12 Jul 2018 21:38:20 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 9EE1AC02D; Fri, 13 Jul 2018 03:26:07 +0200 (CEST) From: Dominique Martinet Cc: Dominique Martinet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Philippe Ombredanne , Thomas Gleixner , Kate Stewart , Greg Kroah-Hartman , Krister Johansen , David Carrillo-Cisneros , Andy Shevchenko , linux-kernel@vger.kernel.org Subject: [PATCH 17/18] perf: change strncpy+truncation to strlcpy Date: Fri, 13 Jul 2018 03:26:06 +0200 Message-Id: <1531445166-19870-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/perf/util/bpf-loader.h | 3 +-- tools/perf/util/util.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/bpf-loader.h b/tools/perf/util/bpf-loader.h index 5d3aefd6fae7..8d08a1fc97a0 100644 --- a/tools/perf/util/bpf-loader.h +++ b/tools/perf/util/bpf-loader.h @@ -143,10 +143,9 @@ __bpf_strerror(char *buf, size_t size) { if (!size) return 0; - strncpy(buf, + strlcpy(buf, "ERROR: eBPF object loading is disabled during compiling.\n", size); - buf[size - 1] = '\0'; return 0; } diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index eac5b858a371..8b9e3aa7aad3 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -459,8 +459,7 @@ fetch_kernel_version(unsigned int *puint, char *str, return -1; if (str && str_size) { - strncpy(str, utsname.release, str_size); - str[str_size - 1] = '\0'; + strlcpy(str, utsname.release, str_size); } if (!puint || int_ver_ready) -- 2.17.1