[dpdk-dev] [PATCH] app/testpmd: fix argument cannot be negative
Daniel Mrzyglod
danielx.t.mrzyglod at intel.com
Tue Jul 25 12:59:54 CEST 2017
Coverity issue: 143454
Fixes: a92a5a2cbbff ("app/testpmd: add command for loading DDP")
Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod at 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
More information about the dev
mailing list