api: fix infinite loop in show api dump CLI 70/35970/2
authorAndrew Yourtchenko <ayourtch@gmail.com>
Fri, 15 Apr 2022 14:23:41 +0000 (14:23 +0000)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Fri, 15 Apr 2022 15:46:57 +0000 (15:46 +0000)
commit105cb1e4cfed2f7a92946fe7e9efc442e0183714
treed4877e6e5fd0787784cef68053d1013b0fb40468
parent8b153de6cdd8d87ae38447487565b346e735dc86
api: fix infinite loop in show api dump CLI

The following illustrates the problem:

./build-root/install-vpp_debug-native/vpp/bin/vpp api-trace { on } unix { cli-listen /tmp/vpp-api-cli.sock } plugins { plugin dpdk_plugin.so { disable } }
sleep 5
./build-root/install-vpp_debug-native/vpp/bin/vppctl -s /tmp/vpp-api-cli.sock show version
./build-root/install-vpp_debug-native/vpp/bin/vppctl -s /tmp/vpp-api-cli.sock show api dump file /tmp/api-table.master-api-baseline compare

The last CLI hangs in an infinite loop.

Fix the typo which got in during the conversion of _vec_len to read-only:

.@@ -1285,7 +1285,7 @@ extract_name (u8 * s)
.   rv = vec_dup (s);
.
.   while (vec_len (rv) && rv[vec_len (rv)] != '_')
.-    _vec_len (rv)--;
.+    vec_dec_len (rv, 0);
.

Type: fix
Fixes: 8bea589cfe0fca1a6f560e16ca66a4cf199041a2
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Change-Id: I4f895348ae0ebaaba9da97c3a440912d38210f10
src/vlibmemory/vlib_api_cli.c