From patchwork Tue Jul 25 10:59:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mrzyglod X-Patchwork-Id: 27167 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 2D94D2C16; Tue, 25 Jul 2017 13:00:23 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 73A542629 for ; Tue, 25 Jul 2017 13:00:21 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 25 Jul 2017 04:00:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,411,1496127600"; d="scan'208"; a="1199097406" Received: from gklab-246-025.igk.intel.com (HELO Sent) ([10.217.246.25]) by fmsmga002.fm.intel.com with SMTP; 25 Jul 2017 04:00:07 -0700 Received: by Sent (sSMTP sendmail emulation); Tue, 25 Jul 2017 12:59:58 +0200 From: Daniel Mrzyglod To: beilei.xing@intel.com Cc: dev@dpdk.org, Daniel Mrzyglod Date: Tue, 25 Jul 2017 12:59:54 +0200 Message-Id: <20170725105954.82081-1-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.13.3 Subject: [dpdk-dev] [PATCH] app/testpmd: fix argument cannot be negative 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Coverity issue: 143454 Fixes: a92a5a2cbbff ("app/testpmd: add command for loading DDP") Signed-off-by: Daniel Mrzyglod --- app/test-pmd/config.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ee6644d10..b77fb96e1 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3292,7 +3292,7 @@ uint8_t * open_ddp_package_file(const char *file_path, uint32_t *size) { FILE *fh = fopen(file_path, "rb"); - uint32_t pkg_size; + off_t pkg_size; uint8_t *buf = NULL; int ret = 0; @@ -3312,6 +3312,12 @@ open_ddp_package_file(const char *file_path, uint32_t *size) } pkg_size = ftell(fh); + if (pkg_size == -1) { + fclose(fh); + printf("%s: The stream specified is not a seekable stream\n" + , __func__); + return buf; + } buf = (uint8_t *)malloc(pkg_size); if (!buf) {