From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4154A5A29 for ; Mon, 29 Jun 2015 16:33:57 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 29 Jun 2015 07:33:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,699,1427785200"; d="scan'208";a="736924152" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.208.162]) by fmsmga001.fm.intel.com with SMTP; 29 Jun 2015 07:33:55 -0700 Received: by (sSMTP sendmail emulation); Mon, 29 Jun 2015 15:33:52 +0025 Date: Mon, 29 Jun 2015 15:33:52 +0100 From: Bruce Richardson To: Daniel Mrzyglod Message-ID: <20150629143352.GA11812@bricha3-MOBL3> References: <1435307833-7432-1-git-send-email-danielx.t.mrzyglod@intel.com> <1435587625-5096-1-git-send-email-danielx.t.mrzyglod@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435587625-5096-1-git-send-email-danielx.t.mrzyglod@intel.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] cfgfile: fix unitialised buffer 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:33:57 -0000 On Mon, Jun 29, 2015 at 04:20:25PM +0200, Daniel Mrzyglod wrote: > Nature of the problem was not initialised buffer[256], there were probability > that operation system will provide previously used memory and on special condition > there were probability that string operations will work on random data that > could provide unexpected program behaviour. > > Signed-off-by: Daniel Mrzyglod > --- > lib/librte_cfgfile/rte_cfgfile.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c > index b81c273..9c85e9f 100644 > --- a/lib/librte_cfgfile/rte_cfgfile.c > +++ b/lib/librte_cfgfile/rte_cfgfile.c > @@ -96,7 +96,10 @@ rte_cfgfile_load(const char *filename, int flags) > int lineno = 0; > struct rte_cfgfile *cfg = NULL; > > + memset(buffer, '\0', sizeof(buffer)); > + > FILE *f = fopen(filename, "r"); > + > if (f == NULL) > return NULL; > > -- > 2.1.0 > How about just adding "= {0}" to the end of the definition of buffer? /Bruce