From: Benoît Ganne Date: Mon, 11 Oct 2021 11:49:59 +0000 (+0200) Subject: api: fix buffer overflow in vl_msg_replay_json X-Git-Tag: v22.06-rc0~356 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=2b9a4bf3b307870324715bab698204f286368cc0;p=vpp.git api: fix buffer overflow in vl_msg_replay_json cJSON_Parse() and vlib_cli_output() expect a NULL-terminated C-string. Type: fix Fixes: 36217e3ca8a1ca2e7a341b6b44ffc25e6497191c Change-Id: Id9819314fcd332c6076d1330b3433885fff07e36 Signed-off-by: Benoît Ganne --- diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c index 268b682f09a..afd145fe620 100644 --- a/src/vlibmemory/vlib_api_cli.c +++ b/src/vlibmemory/vlib_api_cli.c @@ -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; }