[dpdk-dev] Fix buffer overflow issue in app/test/commands.c(we add 1 extra byte for trailing \0).
Commit Message
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(-)
Comments
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
@@ -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;
@@ -150,6 +150,7 @@ main(int argc, char **argv)
}
cmdline_interact(cl);
cmdline_stdin_exit(cl);
+ cmdline_free(cl);
#endif
return 0;