From patchwork Wed Oct 5 11:20:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nickcooper-zhangtonghao X-Patchwork-Id: 678389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3sptdd25swz9s3s for ; Wed, 5 Oct 2016 22:21:25 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 045FB10695; Wed, 5 Oct 2016 04:21:11 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id E6E5910685 for ; Wed, 5 Oct 2016 04:21:09 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 7D65D162BB8 for ; Wed, 5 Oct 2016 05:21:09 -0600 (MDT) X-ASG-Debug-ID: 1475666467-0b32375316d1dd0001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar6.cudamail.com with ESMTP id ATpV5tYL6E0ezy4S (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 05 Oct 2016 05:21:07 -0600 (MDT) X-Barracuda-Envelope-From: nickcooper-zhangtonghao@opencloud.tech X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO smtpbg202.qq.com) (184.105.206.29) by mx3-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 5 Oct 2016 11:21:05 -0000 Received-SPF: none (mx3-pf1.cudamail.com: domain at opencloud.tech does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 184.105.206.29 X-Barracuda-RBL-IP: 184.105.206.29 X-QQ-mid: bizesmtp5t1475666460tmlywcbxi Received: from local.opencloud.tech.localdomai (unknown [117.100.145.25]) by esmtp4.qq.com (ESMTP) with id ; Wed, 05 Oct 2016 19:21:00 +0800 (CST) X-QQ-SSF: 01100000002000F0FFF0B00A0000000 X-QQ-FEAT: jLTfbrzLdoO36NUUmwHl7S+hAVIoat+HKDYqq91ZbtO6/r2hzafFj0gWdh8OR QtM2aEh+vHZl8a0G3GuO9nqo034WnCSVbshSrRywxrNbkRlB0SS6GrpV+eZB86BU/CI9IJM TwgPwwPdItP+y4JohFnk4T/m2US+Fxyj9vnHscv3401y2Ig+7UFITo7iIrnD7K5eSq0Kpr7 tGfSpeC4fzHXLCy7+BmjWm3M3odCpakP+zLYOcqL2WO45EBzremprLM+YEDVCVQM= X-QQ-GoodBg: 0 X-CudaMail-Envelope-Sender: nickcooper-zhangtonghao@opencloud.tech From: nickcooper-zhangtonghao To: dev@openvswitch.org X-CudaMail-MID: CM-V1-1004004858 X-CudaMail-DTE: 100516 X-CudaMail-Originating-IP: 184.105.206.29 Date: Wed, 5 Oct 2016 04:20:44 -0700 X-ASG-Orig-Subj: [##CM-V1-1004004858##][PATCH 3/4] ovn-nbctl: Fix memory leak in nbctl_lr_route_add Message-Id: <1475666445-90772-3-git-send-email-nickcooper-zhangtonghao@opencloud.tech> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1475666445-90772-1-git-send-email-nickcooper-zhangtonghao@opencloud.tech> References: <1475666445-90772-1-git-send-email-nickcooper-zhangtonghao@opencloud.tech> X-QQ-SENDSIZE: 520 X-QQ-Bgrelay: 1 X-GBUdb-Analysis: 0, 184.105.206.29, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-6363-c X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1475666467 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 1.10 X-Barracuda-Spam-Status: No, SCORE=1.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC0_MV0713, BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.33489 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC0_MV0713 Custom rule MV0713 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Cc: nickcooper-zhangtonghao Subject: [ovs-dev] [PATCH 3/4] ovn-nbctl: Fix memory leak in nbctl_lr_route_add X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: nickcooper-zhangtonghao --- ovn/utilities/ovn-nbctl.c | 6 ++++++ tests/ovn-nbctl.at | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 453ff72..572370f 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -2039,17 +2039,22 @@ nbctl_lr_route_add(struct ctl_context *ctx) next_hop = normalize_prefix_str(ctx->argv[3]); if (!next_hop) { + free(prefix); ctl_fatal("bad next hop argument: %s", ctx->argv[3]); } if (strchr(prefix, '.')) { ovs_be32 hop_ipv4; if (!ip_parse(ctx->argv[3], &hop_ipv4)) { + free(prefix); + free(next_hop); ctl_fatal("bad IPv4 nexthop argument: %s", ctx->argv[3]); } } else { struct in6_addr hop_ipv6; if (!ipv6_parse(ctx->argv[3], &hop_ipv6)) { + free(prefix); + free(next_hop); ctl_fatal("bad IPv6 nexthop argument: %s", ctx->argv[3]); } } @@ -2072,6 +2077,7 @@ nbctl_lr_route_add(struct ctl_context *ctx) } if (!may_exist) { + free(next_hop); free(rt_prefix); ctl_fatal("duplicate prefix: %s", prefix); } diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 115d781..af00dad 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -640,6 +640,22 @@ dnl Add overlapping route with 10.0.0.1/24 AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1], [1], [], [ovn-nbctl: duplicate prefix: 10.0.0.0/24 ]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111a/24 11.0.0.1], [1], [], + [ovn-nbctl: bad prefix argument: 10.0.0.111a/24 +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24a 11.0.0.1], [1], [], + [ovn-nbctl: bad prefix argument: 10.0.0.111/24a +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1a], [1], [], + [ovn-nbctl: bad next hop argument: 11.0.0.1a +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 10.0.0.111/24 11.0.0.1/24], [1], [], + [ovn-nbctl: bad IPv4 nexthop argument: 11.0.0.1/24 +]) +AT_CHECK([ovn-nbctl lr-route-add lr0 2001:0db8:1::/64 2001:0db8:0:f103::1/64], [1], [], + [ovn-nbctl: bad IPv6 nexthop argument: 2001:0db8:0:f103::1/64 +]) + AT_CHECK([ovn-nbctl --may-exist lr-route-add lr0 10.0.0.111/24 11.0.0.1]) AT_CHECK([ovn-nbctl lr-route-list lr0], [0], [dnl