From patchwork Mon Feb 4 16:34:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10796085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 59D1C922 for ; Mon, 4 Feb 2019 16:35:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4530B2BA0D for ; Mon, 4 Feb 2019 16:35:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36F062BA4E; Mon, 4 Feb 2019 16:35:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E8A2BA0D for ; Mon, 4 Feb 2019 16:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731704AbfBDQfH (ORCPT ); Mon, 4 Feb 2019 11:35:07 -0500 Received: from foss.arm.com ([217.140.101.70]:58048 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729127AbfBDQfH (ORCPT ); Mon, 4 Feb 2019 11:35:07 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E037115AB; Mon, 4 Feb 2019 08:35:06 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F35AE3F589; Mon, 4 Feb 2019 08:35:05 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: Anisse Astier , kvm@vger.kernel.org Subject: [PATCH kvmtool 1/3] builtin-run: Replace strncpy calls with strlcpy Date: Mon, 4 Feb 2019 16:34:56 +0000 Message-Id: <20190204163458.188070-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190204163458.188070-1-andre.przywara@arm.com> References: <20190204163458.188070-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are two uses of strncpy in builtin-run.c, where we don't make proper use of strncpy, so that GCC 8.x complains and aborts compilation. Replace those two calls with strlcpy(), which does the right thing in our case. Signed-off-by: Andre Przywara --- builtin-run.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin-run.c b/builtin-run.c index 463a481f..f8dc6c72 100644 --- a/builtin-run.c +++ b/builtin-run.c @@ -300,7 +300,7 @@ static const char *find_kernel(void) k++; continue; } - strncpy(kernel, *k, PATH_MAX); + strlcpy(kernel, *k, PATH_MAX); return kernel; } @@ -418,7 +418,7 @@ static void resolve_program(const char *src, char *dst, size_t len) die("Pathname too long: %s -> %s\n", src, resolved_path); } else - strncpy(dst, src, len); + strlcpy(dst, src, len); } static void kvm_run_write_sandbox_cmd(struct kvm *kvm, const char **argv, int argc)