DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error
@ 2017-02-07  2:51 Dmitriy Yakovlev
  2017-02-13 21:07 ` Thomas Monjalon
  2017-02-14 16:46 ` Dumitrescu, Cristian
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitriy Yakovlev @ 2017-02-07  2:51 UTC (permalink / raw)
  To: dev; +Cc: Dmitriy Yakovlev

Uninitialized scalar variable. Using uninitialized value cfg->sections[curr_section]->num_entries when calling rte_cfgfile_close.
And memory in variables cfg->sections[curr_section], sect->entries[curr_entry] maybe not equal NULL. We must decrement counters curr_section, curr_entry when failed to realloc.

Fixes: eaafbad419bf ("cfgfile: library to interpret config files")

Signed-off-by: Dmitriy Yakovlev <bombermag@gmail.com>
---
 lib/librte_cfgfile/rte_cfgfile.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index d72052a..829109a 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -151,6 +151,7 @@ struct rte_cfgfile *
 					sizeof(*cfg) + sizeof(cfg->sections[0])
 					* allocated_sections);
 				if (n_cfg == NULL) {
+					curr_section--;
 					printf("Error - no more memory\n");
 					goto error1;
 				}
@@ -198,6 +199,7 @@ struct rte_cfgfile *
 					sizeof(sect->entries[0]) *
 					allocated_entries);
 				if (n_sect == NULL) {
+					curr_entry--;
 					printf("Error - no more memory\n");
 					goto error1;
 				}
@@ -233,6 +235,8 @@ struct rte_cfgfile *
 
 error1:
 	cfg->num_sections = curr_section + 1;
+	if (curr_section >= 0)
+		cfg->sections[curr_section]->num_entries = curr_entry + 1;
 	rte_cfgfile_close(cfg);
 error2:
 	fclose(f);
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error
  2017-02-07  2:51 [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error Dmitriy Yakovlev
@ 2017-02-13 21:07 ` Thomas Monjalon
  2017-02-14 16:46 ` Dumitrescu, Cristian
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-02-13 21:07 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev, Dmitriy Yakovlev

Ping Cristian

2017-02-07 05:51, Dmitriy Yakovlev:
> Uninitialized scalar variable. Using uninitialized value cfg->sections[curr_section]->num_entries when calling rte_cfgfile_close.
> And memory in variables cfg->sections[curr_section], sect->entries[curr_entry] maybe not equal NULL. We must decrement counters curr_section, curr_entry when failed to realloc.
> 
> Fixes: eaafbad419bf ("cfgfile: library to interpret config files")
> 
> Signed-off-by: Dmitriy Yakovlev <bombermag@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error
  2017-02-07  2:51 [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error Dmitriy Yakovlev
  2017-02-13 21:07 ` Thomas Monjalon
@ 2017-02-14 16:46 ` Dumitrescu, Cristian
  2017-02-14 17:14   ` Thomas Monjalon
  1 sibling, 1 reply; 4+ messages in thread
From: Dumitrescu, Cristian @ 2017-02-14 16:46 UTC (permalink / raw)
  To: Dmitriy Yakovlev, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Dmitriy Yakovlev
> Sent: Tuesday, February 7, 2017 2:51 AM
> To: dev@dpdk.org
> Cc: Dmitriy Yakovlev <bombermag@gmail.com>
> Subject: [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error
> 
> Uninitialized scalar variable. Using uninitialized value cfg-
> >sections[curr_section]->num_entries when calling rte_cfgfile_close.
> And memory in variables cfg->sections[curr_section], sect-
> >entries[curr_entry] maybe not equal NULL. We must decrement counters
> curr_section, curr_entry when failed to realloc.
> 
> Fixes: eaafbad419bf ("cfgfile: library to interpret config files")
> 
> Signed-off-by: Dmitriy Yakovlev <bombermag@gmail.com>
> ---
>  lib/librte_cfgfile/rte_cfgfile.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error
  2017-02-14 16:46 ` Dumitrescu, Cristian
@ 2017-02-14 17:14   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-02-14 17:14 UTC (permalink / raw)
  To: Dmitriy Yakovlev; +Cc: dev, Dumitrescu, Cristian

> > Uninitialized scalar variable. Using uninitialized value cfg-
> > >sections[curr_section]->num_entries when calling rte_cfgfile_close.
> > And memory in variables cfg->sections[curr_section], sect-
> > >entries[curr_entry] maybe not equal NULL. We must decrement counters
> > curr_section, curr_entry when failed to realloc.
> > 
> > Fixes: eaafbad419bf ("cfgfile: library to interpret config files")
> > 
> > Signed-off-by: Dmitriy Yakovlev <bombermag@gmail.com>
> > ---
> >  lib/librte_cfgfile/rte_cfgfile.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> 
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-14 17:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07  2:51 [dpdk-dev] [PATCH] cfgfile: fix uninitialized variable on load error Dmitriy Yakovlev
2017-02-13 21:07 ` Thomas Monjalon
2017-02-14 16:46 ` Dumitrescu, Cristian
2017-02-14 17:14   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).