DPDK patches and discussions
 help / color / mirror / Atom feed
From: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
To: beilei.xing@intel.com
Cc: dev@dpdk.org, Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
Subject: [dpdk-dev] [PATCH] app/testpmd: fix argument cannot be negative
Date: Tue, 25 Jul 2017 12:59:54 +0200	[thread overview]
Message-ID: <20170725105954.82081-1-danielx.t.mrzyglod@intel.com> (raw)

Coverity issue: 143454
Fixes: a92a5a2cbbff ("app/testpmd: add command for loading DDP")

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 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

             reply	other threads:[~2017-07-25 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 10:59 Daniel Mrzyglod [this message]
2017-07-25 12:16 ` Van Haaren, Harry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170725105954.82081-1-danielx.t.mrzyglod@intel.com \
    --to=danielx.t.mrzyglod@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).