Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3632898imu; Mon, 28 Jan 2019 08:09:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN4lHuHXFj5FcpPiQBiXZIUfJywZ3ij5xUuktPR3JOk7saGbkqDYbLFrkKMtglXCNsqq95MG X-Received: by 2002:a17:902:32c3:: with SMTP id z61mr22319798plb.114.1548691786128; Mon, 28 Jan 2019 08:09:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691786; cv=none; d=google.com; s=arc-20160816; b=YUt/i8FNyMD+B/T3DIhcxpbbch44fn2hKlVqyaQyonSwimGN7UpqHYXVbJnTUEuBaI 9kt2FUWKjKYl+qdYCwJ/FOuJ/aJfFP6jqMUPbUQeRPDVWc8deEJlNSx5ZmVVUgVgQCWm 74gVQG2r8Q5egvB1EzfNhiEIuj882GEwEQamw7rWw5/hmMo4wdQkJIdDH5dNopl/ziLh fjR7HuEGPh3oFJAd3Y4zMbSxXJiEYeIvjsjpcHIAqiP+XFAgQ4If4GT1Xsgjn45qrUBY FCyV7wY/0fhBpaxELMzfnxQcFq7V7HKFg84BToj+I4t1NFipLcizJliKgLwNTLNBP4eb qGNg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=U2nwtzxUAcyWiVeQEOACJ6twdEUCPHZk8jrZyB+pl68=; b=UzqlKagWIiCLdW3itSXEiI7L7x7kPIeiSeaqsUWPspoPXtWzmknoX2OLP+fnwr8nXN NzbNWN4gF56pdCjQzNc5XHIcfYbDskJHmqOLXPyaYZpykgKtDlFRv0t0QUBFLUIT4m2a 3ZHwSIisgVm9bsAsowWvOAUXMyqJAl3m6WVwbswx37pPCSBIX4CUyL/L1/oUUsnpdxwz ZU9yNZyKOw88Gm0PsgNl+0Ak4DrNUOL4fBtQm5Vzf8JgSu0vIyGaNeCDltwbSiDtmYwe +itesI214tMDQrJaeEliPGc+ehNNzE/28FXuGf/3m5zkbV+iI75/dVi+lQpIJZmcR5FV Q7+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qnwWPfzE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17si31975033pgl.6.2019.01.28.08.09.30; Mon, 28 Jan 2019 08:09:46 -0800 (PST) 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=qnwWPfzE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732168AbfA1QHR (ORCPT + 99 others); Mon, 28 Jan 2019 11:07:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:57482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730761AbfA1QHM (ORCPT ); Mon, 28 Jan 2019 11:07:12 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C9FF92147A; Mon, 28 Jan 2019 16:07:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691632; bh=Y1gVf3XEPfYUA/5LC1aBJwK7GVnbPX0rc5bztGiTDWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnwWPfzEiAOQN30cFOQhMW1v6GEy4a/2dkOyncG09CDuB0fFgmDe9uh5faorgaYJx 2NSx75cKXiCYD0hJv35KdTpvNOolPHKDMDBhU1aXj912VbH1jJ6oIZaM+Kk7binIGP VLxEBHHIeIduZZcxRq96iiUcYsFfx1DVyJU07pfM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Adrian Hunter , Jiri Olsa , Namhyung Kim , Sasha Levin Subject: [PATCH AUTOSEL 4.19 166/258] perf dso: Fix unchecked usage of strncpy() Date: Mon, 28 Jan 2019 10:57:52 -0500 Message-Id: <20190128155924.51521-166-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore 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 [ Upstream commit fca5085c15255bbde203b7322c15f07ebb12f63e ] The strncpy() function may leave the destination string buffer unterminated, better use strlcpy() that we have a __weak fallback implementation for systems without it. This fixes this warning on an Alpine Linux Edge system with gcc 8.2: In function 'decompress_kmodule', inlined from 'dso__decompress_kmodule_fd' at util/dso.c:305:9: util/dso.c:298:3: error: 'strncpy' destination unchanged after copying no bytes [-Werror=stringop-truncation] strncpy(pathname, tmpbuf, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CC /tmp/build/perf/util/values.o CC /tmp/build/perf/util/debug.o cc1: all warnings being treated as errors Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Fixes: c9a8a6131fb6 ("perf tools: Move the temp file processing into decompress_kmodule") Link: https://lkml.kernel.org/n/tip-tl2hdxj64tt4k8btbi6a0ugw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index bbed90e5d9bb..cee717a3794f 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -295,7 +295,7 @@ static int decompress_kmodule(struct dso *dso, const char *name, unlink(tmpbuf); if (pathname && (fd >= 0)) - strncpy(pathname, tmpbuf, len); + strlcpy(pathname, tmpbuf, len); return fd; } -- 2.19.1