From patchwork Sun Aug 7 21:06:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 656507 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 3s6tSg2rgJz9sRB for ; Mon, 8 Aug 2016 07:08:51 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 1F8CF10646; Sun, 7 Aug 2016 14:08:45 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id 7171E10632 for ; Sun, 7 Aug 2016 14:08:44 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id AD84B1E056F for ; Sun, 7 Aug 2016 15:08:43 -0600 (MDT) X-ASG-Debug-ID: 1470604123-09eadd5e843bb700001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar5.cudamail.com with ESMTP id OAVSOYRrOTSXFFAk (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 07 Aug 2016 15:08:43 -0600 (MDT) X-Barracuda-Envelope-From: bhanuprakash.bodireddy@intel.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mga04.intel.com) (192.55.52.120) by mx1-pf2.cudamail.com with SMTP; 7 Aug 2016 21:08:42 -0000 Received-SPF: pass (mx1-pf2.cudamail.com: SPF record at intel.com designates 192.55.52.120 as permitted sender) X-Barracuda-Apparent-Source-IP: 192.55.52.120 X-Barracuda-RBL-IP: 192.55.52.120 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 07 Aug 2016 14:08:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,486,1464678000"; d="scan'208";a="861301899" Received: from unknown (HELO silpixa00393942.ir.intel.com) ([10.243.18.113]) by orsmga003.jf.intel.com with ESMTP; 07 Aug 2016 14:08:41 -0700 X-CudaMail-Envelope-Sender: bhanuprakash.bodireddy@intel.com From: Bhanuprakash Bodireddy To: dev@openvswitch.org X-CudaMail-MID: CM-E2-806016775 X-CudaMail-DTE: 080716 X-CudaMail-Originating-IP: 192.55.52.120 Date: Sun, 7 Aug 2016 22:06:05 +0100 X-ASG-Orig-Subj: [##CM-E2-806016775##][PATCH 2/2] ovs-appctl: Fix potential crash with timeout argument Message-Id: <1470603965-73273-2-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1470603965-73273-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1470603965-73273-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-GBUdb-Analysis: 0, 192.55.52.120, Ugly c=0.142858 p=-0.5 Source Normal X-MessageSniffer-Rules: 0-0-0-3603-c X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1470604123 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: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.31824 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH 2/2] ovs-appctl: Fix potential crash with timeout argument 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" ovs-appctl can crash with missing timeout argument. # ovs-appctl --timeout= dpif-netdev/pmd-stats-show Fix by using strtol and validating the timeout value. Signed-off-by: Bhanuprakash Bodireddy --- utilities/ovs-appctl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utilities/ovs-appctl.c b/utilities/ovs-appctl.c index 8f87cc4..2543ee9 100644 --- a/utilities/ovs-appctl.c +++ b/utilities/ovs-appctl.c @@ -127,6 +127,7 @@ parse_command_line(int argc, char *argv[]) char *short_options_ = ovs_cmdl_long_options_to_short_options(long_options); char *short_options = xasprintf("+%s", short_options_); const char *target; + int timeout; int e_options; target = NULL; @@ -165,7 +166,13 @@ parse_command_line(int argc, char *argv[]) exit(EXIT_SUCCESS); case 'T': - time_alarm(atoi(optarg)); + timeout = strtol(optarg, NULL, 10); + if (timeout <= 0) { + ovs_fatal(0, "timeout value %s on -t or --timeout is invalid", + optarg); + } else { + time_alarm(timeout); + } break; case 'V':