From patchwork Tue Dec 13 18:52:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alin Serdean X-Patchwork-Id: 705499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tdTNt2X63z9t0q for ; Wed, 14 Dec 2016 05:53:02 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id B581AC11; Tue, 13 Dec 2016 18:52:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D2DD9C0F for ; Tue, 13 Dec 2016 18:52:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.cloudbasesolutions.com (mail.cloudbasesolutions.com [91.232.152.5]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 2EE6B174 for ; Tue, 13 Dec 2016 18:52:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.cloudbasesolutions.com (Postfix) with ESMTP id 2CFFF41706 for ; Tue, 13 Dec 2016 20:52:57 +0200 (EET) X-Virus-Scanned: amavisd-new at cloudbasesolutions.com Received: from mail.cloudbasesolutions.com ([127.0.0.1]) by localhost (mail.cloudbasesolutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hYJDOZYfBAgV for ; Tue, 13 Dec 2016 20:52:36 +0200 (EET) Received: from mail.cloudbasesolutions.com (unknown [10.77.78.3]) by mail.cloudbasesolutions.com (Postfix) with ESMTP id EA85741CC9 for ; Tue, 13 Dec 2016 20:52:36 +0200 (EET) Received: from CBSEX1.cloudbase.local ([10.77.78.3]) by CBSEX1.cloudbase.local ([10.77.78.3]) with mapi id 14.03.0319.002; Tue, 13 Dec 2016 19:52:36 +0100 From: Alin Serdean To: "dev@openvswitch.org" Thread-Topic: [PATCH] windows: Incorrect check while fetching adapter addresses Thread-Index: AQHSVXIRVUoYFG36CkyZREcfnJr49w== Date: Tue, 13 Dec 2016 18:52:35 +0000 Message-ID: <20161213185223.4868-1-aserdean@cloudbasesolutions.com> Accept-Language: en-US, it-IT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.77.78.1] MIME-Version: 1.0 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] windows: Incorrect check while fetching adapter addresses X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Checking for ERROR_INSUFFICIENT_BUFFER is incorrect per MSFT documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365915(v=vs.85).aspx Also, the initial call to GetAdaptersAddresses was wrong. In the case of a successful return 'all_addr' was not allocated leading to a crash. Signed-off-by: Alin Gabriel Serdean Reported-by: Lior Baram Acked-by: Sairam Venugopal --- lib/netdev-windows.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/netdev-windows.c b/lib/netdev-windows.c index f5e809e..c2fbe42 100644 --- a/lib/netdev-windows.c +++ b/lib/netdev-windows.c @@ -425,16 +425,16 @@ netdev_windows_get_next_hop(const struct in_addr *host, { uint32_t ret_val = 0; /* The buffer length of all addresses */ - uint32_t buffer_length = 1000; + uint32_t buffer_length = 0; PIP_ADAPTER_ADDRESSES all_addr = NULL; PIP_ADAPTER_ADDRESSES cur_addr = NULL; ret_val = GetAdaptersAddresses(AF_INET, GAA_FLAG_INCLUDE_PREFIX | GAA_FLAG_INCLUDE_GATEWAYS, - NULL, all_addr, &buffer_length); + NULL, NULL, &buffer_length); - if (ret_val != ERROR_INSUFFICIENT_BUFFER ) { + if (ret_val != ERROR_BUFFER_OVERFLOW ) { VLOG_ERR("Call to GetAdaptersAddresses failed with error: %s", ovs_format_message(ret_val)); return ENXIO;