From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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: , X-List-Received-Date: Tue, 25 Jul 2017 11:00:21 -0000 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) { -- 2.13.3