1. Malloc may return not zero buffer, causing strncat buffer overflow
2. Malloc buffer not freed
Type: fix
Fixes:
31f192434660 ("misc: vppctl - remove the dependency on vppinfra")
Signed-off-by: Tianyu Li <tianyu.li@arm.com>
Change-Id: I5aebaccf3d0f8b7e3617068267f62cc2aa39d827
{
cmd_len++; // account for \n in the end
cmd = malloc (cmd_len);
+ if (!cmd)
+ {
+ error = errno;
+ perror ("malloc failed");
+ goto done;
+ }
+ memset (cmd, 0, cmd_len);
while (argc--)
{
strncat (cmd, *argv++, cmd_len);
close (sock_fd);
done:
+ free (cmd);
if (efd > -1)
close (efd);