From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnaldo Carvalho de Melo Subject: Re: [PATCH 05/44] perf data: Fix 'strncat may truncate' build failure with recent gcc Date: Tue, 28 May 2019 10:04:21 -0300 Message-ID: <20190528130421.GB13830@kernel.org> References: <20190527223730.11474-1-acme@kernel.org> <20190527223730.11474-6-acme@kernel.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Shawn Landden Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Adrian Hunter , Jiri Olsa , Wang Nan , Arnaldo Carvalho de Melo List-Id: linux-perf-users.vger.kernel.org Em Mon, May 27, 2019 at 05:46:26PM -0500, Shawn Landden escreveu: > On Mon, May 27, 2019 at 5:38 PM Arnaldo Carvalho de Melo > wrote: > > > > From: Shawn Landden > > > > 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 > > --- > > 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 e0311c9750ad..9097543a818b 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); > I took care to have enough context in my patch that you could see what > was going on. I wonder if there is a way to make that care > propate when people add Signed-off-by: lines. I just checked and the patch is the same, the description I only changed the subject line, so that when one uses: git log --oneline we can know what is the component and what kind of build failure was that. - Arnaldo > > p += 3; > > } > > } > > -- > > 2.20.1 > > -- - Arnaldo