[dpdk-dev,v3] cfgfile: fix unitialised buffer

Message ID 1435590363-4656-1-git-send-email-danielx.t.mrzyglod@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Daniel Mrzyglod June 29, 2015, 3:06 p.m. UTC
  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.

Changes in v3:
-Simplify the initialization of buffer.
Changes in v2:
-Found the real nature of problem. Only buffer was not initilized.
Changes in v1:
-Add additional separate IO buffer and initialize both buffers.

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 lib/librte_cfgfile/rte_cfgfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Cristian Dumitrescu June 29, 2015, 7:47 p.m. UTC | #1
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod
> Sent: Monday, June 29, 2015 4:06 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v3] cfgfile: fix unitialised buffer
> 
> 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.
> 
> Changes in v3:
> -Simplify the initialization of buffer.
> Changes in v2:
> -Found the real nature of problem. Only buffer was not initilized.
> Changes in v1:
> -Add additional separate IO buffer and initialize both buffers.
> 
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  
Thomas Monjalon July 1, 2015, 9:36 p.m. UTC | #2
2015-06-29 19:47, Dumitrescu, Cristian:
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod
> > 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.
> > 
> > Changes in v3:
> > -Simplify the initialization of buffer.
> > Changes in v2:
> > -Found the real nature of problem. Only buffer was not initilized.
> > Changes in v1:
> > -Add additional separate IO buffer and initialize both buffers.
> > 
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index b81c273..a677dad 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -92,7 +92,7 @@  rte_cfgfile_load(const char *filename, int flags)
 	int allocated_entries = 0;
 	int curr_section = -1;
 	int curr_entry = -1;
-	char buffer[256];
+	char buffer[256] = {0};
 	int lineno = 0;
 	struct rte_cfgfile *cfg = NULL;