api: fix buffer overflow in vl_msg_replay_json

cJSON_Parse() and vlib_cli_output() expect a NULL-terminated C-string.

Type: fix
Fixes: 36217e3ca8

Change-Id: Id9819314fcd332c6076d1330b3433885fff07e36
Signed-off-by: Benoît Ganne <bganne@cisco.com>
This commit is contained in:
Benoît Ganne
2021-10-11 13:49:59 +02:00
committed by Ole Tr�an
parent 93bca19f1e
commit 2b9a4bf3b3

View File

@@ -785,6 +785,10 @@ vl_msg_read_file (FILE *f)
while ((n = fread (buf, 1, bufsize, f)))
vec_add (v, buf, n);
/* most callers expect a NULL-terminated C-string */
if (v)
vec_add1 (v, 0);
return v;
}