From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 5E070201 for ; Tue, 25 Jul 2017 14:16:52 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 05:16:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="1199117679" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by fmsmga002.fm.intel.com with ESMTP; 25 Jul 2017 05:16:47 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.211]) by irsmsx105.ger.corp.intel.com ([169.254.7.168]) with mapi id 14.03.0319.002; Tue, 25 Jul 2017 13:16:15 +0100 From: "Van Haaren, Harry" To: "Mrzyglod, DanielX T" CC: "dev@dpdk.org" , "Xing, Beilei" Thread-Topic: [dpdk-dev] [PATCH] app/testpmd: fix argument cannot be negative Thread-Index: AQHTBTVDa63ST322cUepoEIqAD0/1KJkb9fA Date: Tue, 25 Jul 2017 12:16:14 +0000 Message-ID: References: <20170725105954.82081-1-danielx.t.mrzyglod@intel.com> In-Reply-To: <20170725105954.82081-1-danielx.t.mrzyglod@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzY2NzI1ODgtYjliZS00NDFkLTkzODItYTI2Y2U1OGRhMjllIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IklxY09kT0RmdCtwd1BZdUh2RlkxM0p5UWRucUdua3p5U01ielc3cUpJc009In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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 12:16:53 -0000 Hi Daniel, > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod > Sent: Tuesday, July 25, 2017 12:00 PM > To: Xing, Beilei > Cc: dev@dpdk.org; Mrzyglod, DanielX T > Subject: [dpdk-dev] [PATCH] app/testpmd: fix argument cannot be negative Sorry for the nit-pick review, but there should be some description here in the commit message, describing what was fixed. I see it is stated in the title, but a short paragraph stating the issue and what wrong effect the patch fixes is very useful in git bisect :) Comments on code below, -Harry > Coverity issue: 143454 > Fixes: a92a5a2cbbff ("app/testpmd: add command for loading DDP") >=20 > Signed-off-by: Daniel Mrzyglod > --- > app/test-pmd/config.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) >=20 > 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 =3D fopen(file_path, "rb"); > - uint32_t pkg_size; > + off_t pkg_size; I don't see a mention of off_t anywhere else in this file, perhaps use a commonly used datatype that is suitable to hold the "long int" that ftell() returns, eg: int64_t ? > uint8_t *buf =3D NULL; > int ret =3D 0; >=20 > @@ -3312,6 +3312,12 @@ open_ddp_package_file(const char *file_path, uint3= 2_t *size) > } >=20 > pkg_size =3D ftell(fh); > + if (pkg_size =3D=3D -1) { > + fclose(fh); > + printf("%s: The stream specified is not a seekable stream\n" > + , __func__); > + return buf; > + } Given that malloc(0) is implementation defined, we should probably check to ensure that pkg_size is > 0 before malloc(). Perhaps not explicitly called out by coverity in this case, but worth fixing as that code is being modified already. >=20 > buf =3D (uint8_t *)malloc(pkg_size); > if (!buf) { > -- > 2.13.3