From patchwork Mon Feb 4 16:34:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10796089 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 0482F6C2 for ; Mon, 4 Feb 2019 16:35:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E7A992BA0D for ; Mon, 4 Feb 2019 16:35:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC0CB2BA4E; Mon, 4 Feb 2019 16:35:10 +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 957592BA1E for ; Mon, 4 Feb 2019 16:35:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731745AbfBDQfJ (ORCPT ); Mon, 4 Feb 2019 11:35:09 -0500 Received: from foss.arm.com ([217.140.101.70]:58064 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731725AbfBDQfJ (ORCPT ); Mon, 4 Feb 2019 11:35:09 -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 3CA9E15AB; Mon, 4 Feb 2019 08:35:09 -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 514933F589; Mon, 4 Feb 2019 08:35:08 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: Anisse Astier , kvm@vger.kernel.org Subject: [PATCH kvmtool 3/3] net/dhcp: avoid misleading strncpy Date: Mon, 4 Feb 2019 16:34:58 +0000 Message-Id: <20190204163458.188070-4-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 The code for copying an empty IP address into the DHCP opt buffer used strncpy, however used the source length as the size argument. GCC 8.x complains about it. Since the source string is actually fixed, just revert to the old strcpy, which gives us actually the same level of security in this case, but makes the compiler happy. Signed-off-by: Andre Przywara --- net/uip/dhcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/uip/dhcp.c b/net/uip/dhcp.c index 8f013002..9de5588b 100644 --- a/net/uip/dhcp.c +++ b/net/uip/dhcp.c @@ -131,7 +131,7 @@ static int uip_dhcp_fill_option(struct uip_info *info, struct uip_dhcp *dhcp, in opt[i++] = UIP_DHCP_TAG_ROOT; opt[i++] = strlen(EMPTY_ADDR); addr = (u32 *)&opt[i]; - strncpy((void *) addr, EMPTY_ADDR, strlen(EMPTY_ADDR)); + strcpy((void *) addr, EMPTY_ADDR); i += strlen(EMPTY_ADDR); i = uip_dhcp_fill_option_name_and_server(info, opt, i);