DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] Fix buffer overflow issue in app/test/commands.c(we add 1 extra byte for trailing \0).
@ 2016-02-26  7:11 Ming Zhao
  2016-03-05 22:09 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Ming Zhao @ 2016-02-26  7:11 UTC (permalink / raw)
  To: dev

Fix memleak of cmdline in app/test/test.c
---
 app/test/commands.c | 2 +-
 app/test/test.c     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test/commands.c b/app/test/commands.c
index 9cb9606..5dfa599 100644
--- a/app/test/commands.c
+++ b/app/test/commands.c
@@ -439,7 +439,7 @@ int commands_init(void)
 		commands_len += strlen(t->command) + 1;
 	}
 
-	commands = malloc(commands_len);
+	commands = malloc(commands_len + 1); /* one more byte for \0 */
 	if (!commands)
 		return -1;
 
diff --git a/app/test/test.c b/app/test/test.c
index f35b304..108a347 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -150,6 +150,7 @@ main(int argc, char **argv)
 	}
 	cmdline_interact(cl);
 	cmdline_stdin_exit(cl);
+        cmdline_free(cl);
 #endif
 
 	return 0;
-- 
1.9.1

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

* Re: [dpdk-dev] [PATCH] Fix buffer overflow issue in app/test/commands.c(we add 1 extra byte for trailing \0).
  2016-02-26  7:11 [dpdk-dev] [PATCH] Fix buffer overflow issue in app/test/commands.c(we add 1 extra byte for trailing \0) Ming Zhao
@ 2016-03-05 22:09 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2016-03-05 22:09 UTC (permalink / raw)
  To: Ming Zhao; +Cc: dev

Hi,

2016-02-25 23:11, Ming Zhao:
> Fix memleak of cmdline in app/test/test.c

It looks to be two different fixes:
- an overflow
- a memleak

Please send 2 patches,
with Fixes lines (even if is there since the first commit),
with Signed-off-by line.
See http://dpdk.org/doc/guides/contributing/patches.html#commit-messages-subject-line

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

end of thread, other threads:[~2016-03-05 22:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26  7:11 [dpdk-dev] [PATCH] Fix buffer overflow issue in app/test/commands.c(we add 1 extra byte for trailing \0) Ming Zhao
2016-03-05 22:09 ` 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).