initctl: ensure the returned plugin buffer data is terminated

Found by Coverity Scan

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2023-03-04 11:43:10 +01:00
1 parent f4d8ecfb5b
commit 67e80ea989
1 file changed
+3 -2
+3 -2
View File
@@ -717,7 +717,7 @@ static int plugins_list(char *arg)
.magic = INIT_MAGIC, .magic = INIT_MAGIC,
.cmd = INIT_CMD_GET_PLUGINS, .cmd = INIT_CMD_GET_PLUGINS,
}; };
char buf[sizeof(rq.data)]; char buf[sizeof(rq.data) + 1];
char *ptr; char *ptr;
int rc; int rc;
@@ -728,7 +728,8 @@ static int plugins_list(char *arg)
else else
ERRX(69, "No such command"); ERRX(69, "No such command");
} }
memcpy(buf, rq.data, sizeof(buf)); memcpy(buf, rq.data, sizeof(buf) - 1);
buf[sizeof(rq.data)] = 0;
if (heading) if (heading)
print_header("%-18s %s", "PLUGIN", "DEPENDENCIES"); print_header("%-18s %s", "PLUGIN", "DEPENDENCIES");