Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7101406ybi; Mon, 8 Jul 2019 14:36:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhUhfb/J1978PuFVVCXViv0VeNcbJBd0JuHU2OuDGeEMVq9FU3Zyw3DF5KGl4q4tk2ZrmH X-Received: by 2002:a65:640a:: with SMTP id a10mr25900705pgv.338.1562621815504; Mon, 08 Jul 2019 14:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562621815; cv=none; d=google.com; s=arc-20160816; b=PeoKPOtjKezx1qhly2WBw/77e4c8sLiaR9bFXWxbGWM/kfffFVzkpo5sYj6VC940zf EwqNLtOqJu8mUpSEC+zFTz2TwveRMhwUs6V94Rvlwk5t4qMJpA54SsrhgYPeDWdYZBgl /0wm4cYKru0MZv0DaS5nrPmROFE7T9ephjvAAFqCuIUTS1HPSOQjnDLG2z06DJuZHNxL eqT20IyCaPOWLFiEHORU/lKEeKhkm896x8Wfk3Sg3BR+/413fwfTjTWdVBtamIlUqTZz S46pZdoJYxzuqoATzxSanFRgiSYS48nIUXNVI9gzZpNppvkiRRuTfNuz0NnHxmyhk67K bVbQ== 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=cayd0a8i2qTIFnJgXVY0Rouunek438wYTEswhfS6AFY=; b=HOhAbUmUhTdgRqMsqiTUxhZjHXTWqQt6ZvqI1RLsmF1ghUBQeoz0o7kDyCTrYna/dc FO35FrkU3nth/BAxSWZrI84ohm6TMsc+9EE8ZWr4dar8oRDTOHo0WcXX8Bw/en7LkjBT tNBaFckpxJkKv4aYKinNAedCoODtefBwSBXMBb1QSTLdHLImM6IwS3qRb4Ei0zgdcC7Z mEBHuUYbBlTRkuBZGdcnypnCtkbv7WSi86qlBFw0LkZCwfJut7irbwuGXiA7Kc1n5gfY Gq/SewEhZ3iG2aYUQMuuQZSZx/ltjP7c9itTBF8lpfeAqIkrIkjF6C3yahgYphd1Xp+Z wupQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BrRfn3aU; 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 r9si641741pjq.35.2019.07.08.14.36.40; Mon, 08 Jul 2019 14:36: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; dkim=pass header.i=@kernel.org header.s=default header.b=BrRfn3aU; 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 S1732785AbfGHPRT (ORCPT + 99 others); Mon, 8 Jul 2019 11:17:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:40482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732777AbfGHPRO (ORCPT ); Mon, 8 Jul 2019 11:17:14 -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 3862E2166E; Mon, 8 Jul 2019 15:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599033; bh=fHVNVZ/yi3kAe7zp1/zq7MgpT0N4EdP/+nIB0OHB9BY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BrRfn3aUa45dzJRVHSqsOwEQL+K+J8H2dzu14Qx+K/dkNA70zdsUUKp/6NOmTxZlB g/bCFJDIk5GztoK0HtkzdEHFM+S1bLgJ1+MMf/RQxpPsHPiG1OUghmm4J8Pbp4XA2H RQgj623eUujfebjH9hMHw/yCYkiBeoEdBL1fY/sY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 4.4 29/73] perf ui helpline: Use strlcpy() as a shorter form of strncpy() + explicit set nul Date: Mon, 8 Jul 2019 17:12:39 +0200 Message-Id: <20190708150522.673884057@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150513.136580595@linuxfoundation.org> References: <20190708150513.136580595@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 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: Greg Kroah-Hartman --- 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 @@ -23,7 +23,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)