From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 255855A29 for ; Mon, 29 Jun 2015 16:32:05 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 29 Jun 2015 07:32:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,699,1427785200"; d="scan'208";a="596750063" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by orsmga003.jf.intel.com with ESMTP; 29 Jun 2015 07:32:02 -0700 Received: from irsmsx107.ger.corp.intel.com ([169.254.10.39]) by IRSMSX152.ger.corp.intel.com ([169.254.6.90]) with mapi id 14.03.0224.002; Mon, 29 Jun 2015 15:32:02 +0100 From: "Mrzyglod, DanielX T" To: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] cfgfile: fix unitialised buffer and improve reading from nfs filesystem. Thread-Index: AQHQr+t/QhPHZbSGO0Gf6ldzbnAdbp3DjlDw Date: Mon, 29 Jun 2015 14:32:01 +0000 Message-ID: <7ADD74816B4C8A45B56203CBA65FE5A61D908D9C@IRSMSX107.ger.corp.intel.com> References: <1435307833-7432-1-git-send-email-danielx.t.mrzyglod@intel.com> In-Reply-To: <1435307833-7432-1-git-send-email-danielx.t.mrzyglod@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: 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] cfgfile: fix unitialised buffer and improve reading from nfs filesystem. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jun 2015 14:32:07 -0000 I send v2 of this patch.=20 I removed in v2 special buffer for file descriptor. It helped when we haved unitilized buffer[256] because of diferent fgets/fr= ead/fwrite behaviour when the buffer was set.=20 The real and only problem was uninitialized buffer[256] and this workaround= IO buffer is not needed for patch. > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod > Sent: Friday, June 26, 2015 10:37 AM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] cfgfile: fix unitialised buffer and improve r= eading > from nfs filesystem. >=20 > Nature of the problem was not initialised buffer[256] on special conditio= n > there were probability that program will work on unitialised data that > could provide unexpected program behaviour. >=20 > Adding additional transparent I/O buffer for I/O operations > improve reading on heavyloaded enviroments with NFS. >=20 > Signed-off-by: Daniel Mrzyglod > --- > lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cf= gfile.c > index b81c273..88fcb46 100644 > --- a/lib/librte_cfgfile/rte_cfgfile.c > +++ b/lib/librte_cfgfile/rte_cfgfile.c > @@ -93,10 +93,14 @@ rte_cfgfile_load(const char *filename, int flags) > int curr_section =3D -1; > int curr_entry =3D -1; > char buffer[256]; > + char f_streambuff[BUFSIZ]; > int lineno =3D 0; > struct rte_cfgfile *cfg =3D NULL; > + memset(buffer, '\0', 256*sizeof(char)); > + memset(f_streambuff, '\0', BUFSIZ); >=20 > FILE *f =3D fopen(filename, "r"); > + setbuf(f, f_streambuff); > if (f =3D=3D NULL) > return NULL; >=20 > -- > 2.1.0