Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1319757yba; Tue, 2 Apr 2019 06:48:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqzknrLvpRfpzdvIyz6QKANOy8DZF0wVavLoym53J56c01KWH/MG/FP0ajZX3bPCN9haXHJ0 X-Received: by 2002:a17:902:be0a:: with SMTP id r10mr56349483pls.4.1554212936023; Tue, 02 Apr 2019 06:48:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212936; cv=none; d=google.com; s=arc-20160816; b=kmsRJ8LJPwVG3yV6cckzAXkiTSICXhksR7x7ud1hOhZCzVDgj0JoV8q5gJhf7hFhC7 /eDAHTvRl6itZC671rg7b1R0rtYz9RB9y6kQOb32GO1/qFJnU78JJO+n3IntJtq2pn2X SeRdPD7N9EYLvLIlQgxl/PP3f5a8p4Vpg6In2p/oxNao8SdWoGwQVI4CeAAn48Pyzgef 3sWXj0P5jZEDREHzAWKyQ4arKNs7huDne5vZ2oVKIGRCyjSQQYdnreVD7JTsP4WyjggS IcI7deRAcmTmwTROMop3VOX/qDJlYd1nRVMBN3L2sWNBB6OA/LOb4nL2yClaahASyKB9 oQpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=jfj/RhlUlswfWeeHL0n1UeiB41Lcu5KAna8n4JJEyg4=; b=eeFfOYr/yeeJkePuHUUhTzBC/yc2BwRd5+3Z+n5qJevRJEaycXom+fMRc0VznENBf7 Oi5rR9PzCGaxLqU3tuI8qbTx6Wo7cVD0FZYgcHpFSSjep/z1tGtRtmiyDp8IyjZJZuPc +gX1GA4C1Y5BP6xXkcSLSA6adNrRC8KTz3eBBMj1gQrV/FNK9VqCJZekk5eY/gnvl90b 6FTiG93zrYF9ZbMb4LAYNoPGP5yodGNNtxGM03V6hwFD0KVXlSc60wm0YTox8LSgqcO1 RCA45hv7hFMuaogAXoN3d8i2NPWVG3OwRTa+nIIzO5Jwq1GmQ0CAOBIdID5xzdFxnBvF ezdw== 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 l40si11790432plb.164.2019.04.02.06.48.41; Tue, 02 Apr 2019 06:48:56 -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 S1732179AbfDBNqO (ORCPT + 99 others); Tue, 2 Apr 2019 09:46:14 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43144 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731426AbfDBNkF (ORCPT ); Tue, 2 Apr 2019 09:40:05 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdw-0002oR-VX; Tue, 02 Apr 2019 14:40:01 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdw-0004tj-4c; Tue, 02 Apr 2019 14:40:00 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Namhyung Kim" , "Arnaldo Carvalho de Melo" , "Jiri Olsa" , "Adrian Hunter" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 41/99] perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Arnaldo Carvalho de Melo commit 4d0f16d059ddb91424480d88473f7392f24aebdc upstream. The strncpy() function may leave the destination string buffer unterminated, better use strlcpy() that we have a __weak fallback implementation for systems without it. In this case we are actually setting the null byte at the right place, but since we pass the buffer size as the limit to strncpy() and not it minus one, gcc ends up warning us about that, see below. So, lets just switch to the shorter form provided by strlcpy(). This fixes this warning on an Alpine Linux Edge system with gcc 8.2: ui/tui/helpline.c: In function 'tui_helpline__push': ui/tui/helpline.c:27:2: error: 'strncpy' specified bound 512 equals destination size [-Werror=stringop-truncation] strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0'; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Fixes: e6e904687949 ("perf ui: Introduce struct ui_helpline") Link: https://lkml.kernel.org/n/tip-d1wz0hjjsh19xbalw69qpytj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Ben Hutchings --- tools/perf/ui/tui/helpline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/tools/perf/ui/tui/helpline.c +++ b/tools/perf/ui/tui/helpline.c @@ -22,7 +22,7 @@ static void tui_helpline__push(const cha SLsmg_set_color(0); SLsmg_write_nstring((char *)msg, SLtt_Screen_Cols); SLsmg_refresh(); - strncpy(ui_helpline__current, msg, sz)[sz - 1] = '\0'; + strlcpy(ui_helpline__current, msg, sz); } static int tui_helpline__show(const char *format, va_list ap)