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)
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

index bdbedec..39e2250 100644 (file)
@@ -1285,7 +1285,7 @@ extract_name (u8 * s)
   rv = vec_dup (s);
 
   while (vec_len (rv) && rv[vec_len (rv)] != '_')
-    vec_dec_len (rv, 0);
+    vec_dec_len (rv, 1);
 
   rv[vec_len (rv)] = 0;