From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 912E81B3A9; Tue, 4 Dec 2018 07:16:20 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2018 22:16:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,312,1539673200"; d="scan'208";a="98448817" Received: from dpdk6.bj.intel.com ([172.16.182.192]) by orsmga008.jf.intel.com with ESMTP; 03 Dec 2018 22:16:18 -0800 From: Wei Zhao To: dev@dpdk.org Cc: stable@dpdk.org, yuan.peng@intel.com, Wei Zhao Date: Tue, 4 Dec 2018 13:51:30 +0800 Message-Id: <1543902690-71857-1-git-send-email-wei.zhao1@intel.com> X-Mailer: git-send-email 2.7.5 Subject: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Dec 2018 06:16:21 -0000 There is need to add boundary for input number from commandline, If it beyond the defination, code will return error. Signed-off-by: Wei Zhao --- app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 23ea7cc..515f95c 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct token *token, } buf = (uint8_t *)ctx->object + arg->offset; size = arg->size; + switch (size) { + case sizeof(uint8_t): + if (u > 0xff) + return -1; + case sizeof(uint16_t): + if (u > 0xffff) + return -1; + case sizeof(uint8_t [3]): + if (u > 0xffffff) + return -1; + case sizeof(uint32_t): + if (u > 0xffffffff) + return -1; + case sizeof(uint64_t): + if (u > 0xffffffffffffffff) + return -1; + default: + break; + } objmask: switch (size) { case sizeof(uint8_t): -- 2.7.5