aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2020-07-16 12:03:35 +0200
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-08-18 19:47:21 +0000
commit526906751067ff66a87bab591766bc0ff4b91095 (patch)
treeb6c91d99441ea3a1ca6bbeb84733694fda470522 /src
parentd48d51df239fbc2f64727a74841926e33fc8019c (diff)
vppinfra: fix format_c_identifier vector overflow
In case of vector, we must check length before trying to access element. Also fix wrong DPDK plugin workaround. Type: fix Change-Id: I2ecef1c88ebef2362f48cab0d462699aa43cd4b9 Signed-off-by: Benoît Ganne <bganne@cisco.com> (cherry picked from commit 1bd6f61820c6c15534ebb04a4b070ba84bf08a9d)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/dpdk/device/format.c6
-rw-r--r--src/vppinfra/std-formats.c2
2 files changed, 3 insertions, 5 deletions
diff --git a/src/plugins/dpdk/device/format.c b/src/plugins/dpdk/device/format.c
index 942def63b0a..436466fa1ad 100644
--- a/src/plugins/dpdk/device/format.c
+++ b/src/plugins/dpdk/device/format.c
@@ -676,12 +676,10 @@ format_dpdk_device (u8 * s, va_list * args)
xstat = vec_elt_at_index(xd->xstats, i);
if (verbose == 2 || (verbose && xstat->value))
{
- /* format_c_identifier doesn't like c strings inside vector */
- u8 * name = format(0,"%s", xstat_names[i].name);
xs = format(xs, "\n%U%-38U%16Lu",
format_white_space, indent + 4,
- format_c_identifier, name, xstat->value);
- vec_free(name);
+ format_c_identifier, xstat_names[i].name,
+ xstat->value);
}
}
/* *INDENT-ON* */
diff --git a/src/vppinfra/std-formats.c b/src/vppinfra/std-formats.c
index b771b947e27..62d309e2fb0 100644
--- a/src/vppinfra/std-formats.c
+++ b/src/vppinfra/std-formats.c
@@ -281,7 +281,7 @@ format_c_identifier (u8 * s, va_list * va)
l = vec_len (id);
if (id)
- for (i = 0; id[i] != 0 && i < l; i++)
+ for (i = 0; i < l && id[i] != 0; i++)
{
u8 c = id[i];