Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2231165ybi; Thu, 20 Jun 2019 11:16:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuCQST9cX53IQiYeCikwMqAYdNDw10ew0z33VNzwC1th159dRUqvY+3auCYhHt6b/kGhgl X-Received: by 2002:a63:8a41:: with SMTP id y62mr2754403pgd.38.1561054568819; Thu, 20 Jun 2019 11:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054568; cv=none; d=google.com; s=arc-20160816; b=Zuuvs6Spa3mtaYT00Wcf83yRRxfpR9fEb/OuA1Du5KwUuO2oOV+suXLC5rZ53oTjvJ 55l7761si1gJQzIdH8D5i0cth+UTbKM/1KzvfCj820Pt10xXYCcla/ScbzebdLbuIfFh yqsezKbQWn3zLE5KgqSAkPVUxZuFerhzcq8Ti3MrOCalKN8WlVeXSoL9viIltDuXyWIG id6Orkb/GRC+5RiJY2vFTQ3wmyt7QNXKk+MDsckYQo9weRX6GsFHUTarrikqcQBRSZS+ Q9hST8qYaOWoC2xkOvqyuLH7WVkpzMQIVO5Z28Q0z5MBitCEWu+vORzzUSXZpYhs6SWl xvqw== 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=OwnG56KXa8kPlI4apujnjPKSHIra3YXSmP1kz6fwK28=; b=SRwuWf5CJKIscFEhd3nooGx69q0y96Hue6SkqQP3xaKRx82OjidwwCbmzG++jcmsa5 DT/RsiAis7FgmjnEpJEQnwT96dNo/BO6gjOr4H7TCAuqQghJVI+ARX3IiPiV/7eM61CB ymxDJ5pdbK4uwjgMCsG476lQDDZvD9bfZO0ZWtXjGnGQ944Xf9oJr2Zb0ES1iNl60jYQ xDzzremZ9rblJfKdx5FjQHPEw8GefCo+GAdWi4teCH+WsL2Fjzfl+JSvDKGbl4C7mlkC pEhEVkWdIotXkwRMQQatpW7443yfyQqPxS0BZBE564I+Pv+95TPFNViLnL74RH/cB/f7 J6Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aRUp0y3g; 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 f6si334379plo.382.2019.06.20.11.15.53; Thu, 20 Jun 2019 11:16:08 -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; dkim=pass header.i=@kernel.org header.s=default header.b=aRUp0y3g; 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 S1729050AbfFTSPv (ORCPT + 99 others); Thu, 20 Jun 2019 14:15:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729664AbfFTSPs (ORCPT ); Thu, 20 Jun 2019 14:15:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 3FA6921655; Thu, 20 Jun 2019 18:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054547; bh=FroEYVST/e4gxg+Bs7HMolCHkXeg9Vc1AUqUnginIGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aRUp0y3gSgjSza+gUFN2phcCvONzgfDntj6jY8quDd68kDmPSLehooPqfhlN4CvJ8 rCMzwJmAcz/6W4cijvfLA7/9EZLMbNyoNy67HppvTPaRLVfpbHqsu5Xq761jrgn+Uq pEKf5Iw/3sM2UWLgQwobueyiS72/249j7ITun5iA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shawn Landden , Adrian Hunter , Jiri Olsa , Namhyung Kim , Wang Nan , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.1 66/98] perf data: Fix strncat may truncate build failure with recent gcc Date: Thu, 20 Jun 2019 19:57:33 +0200 Message-Id: <20190620174352.453052555@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 97acec7df172cd1e450f81f5e293c0aa145a2797 ] This strncat() is safe because the buffer was allocated with zalloc(), however gcc doesn't know that. Since the string always has 4 non-null bytes, just use memcpy() here. CC /home/shawn/linux/tools/perf/util/data-convert-bt.o In file included from /usr/include/string.h:494, from /home/shawn/linux/tools/lib/traceevent/event-parse.h:27, from util/data-convert-bt.c:22: In function ‘strncat’, inlined from ‘string_set_value’ at util/data-convert-bt.c:274:4: /usr/include/powerpc64le-linux-gnu/bits/string_fortified.h:136:10: error: ‘__builtin_strncat’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation] 136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Shawn Landden Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan LPU-Reference: 20190518183238.10954-1-shawn@git.icu Link: https://lkml.kernel.org/n/tip-289f1jice17ta7tr3tstm9jm@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/data-convert-bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 26af43ad9ddd..53d49fd8b8ae 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -271,7 +271,7 @@ static int string_set_value(struct bt_ctf_field *field, const char *string) if (i > 0) strncpy(buffer, string, i); } - strncat(buffer + p, numstr, 4); + memcpy(buffer + p, numstr, 4); p += 3; } } -- 2.20.1