Actions
Bug #6360
openlibosmovty fails to parse commands like "test (foo|bar) [(one|two|three)]"
Status:
New
Priority:
Normal
Assignee:
-
Category:
libosmovty
Target version:
-
Start date:
02/15/2024
Due date:
% Done:
0%
Spec Reference:
Description
Support for the [(one|two|three)]
syntax was added back in 2019:
commit b55f4d2df21b966c3953264d8961f259814f4650 Author: Neels Hofmeyr <neels@hofmeyr.de> Date: Thu Jan 31 08:13:31 2019 +0100 vty: enable optional-multi-choice syntax: [(one|two)]
https://cgit.osmocom.org/libosmocore/commit/?id=b55f4d2df21b966c3953264d8961f259814f4650
However the VTY parser still hits an assertion if the command has a non-optional choice preceding an optional one:
test (foo|bar) [(one|two|three)]
Here is a patch extending the existing testing coverage and reproducing the problem:
https://gerrit.osmocom.org/c/libosmocore/+/35961
$ gdb ./tests/vty/vty_transcript_test (gdb) r Program received signal SIGABRT, Aborted. 0x00007ffff7d8b83c in ?? () from /usr/lib/libc.so.6 (gdb) bt #0 0x00007ffff7d8b83c in ?? () from /usr/lib/libc.so.6 #1 0x00007ffff7d3b668 in raise () from /usr/lib/libc.so.6 #2 0x00007ffff7d234b8 in abort () from /usr/lib/libc.so.6 #3 0x00007ffff7f3d511 in osmo_panic_default (fmt=0x7ffff7fb112c "Assert failed %s %s:%d\n", args=0x7fffffffddc0) at panic.c:45 #4 0x00007ffff7f3d4c5 in osmo_panic (fmt=0x7ffff7fb112c "Assert failed %s %s:%d\n") at panic.c:80 #5 0x00007ffff7f96d83 in cmd_make_descvec (string=0x55555555734f "multi3 (foo|bar) [(one|two|three)]", descstr=0x555555557372 "multi3 test command\nfoo\nbar\n1\n2\n3\n") at command.c:439 #6 0x00007ffff7f96add in install_element (ntype=1, cmd=0x555555559388 <multi3_cmd>) at command.c:1009 #7 0x00007ffff7f9718a in install_element_ve (cmd=0x555555559388 <multi3_cmd>) at command.c:1026 #8 0x0000555555556570 in init_vty_cmds () at vty/vty_transcript_test.c:391 #9 0x0000555555556384 in main (argc=1, argv=0x7fffffffe018) at vty/vty_transcript_test.c:429 (gdb) frame 5 #5 0x00007ffff7f96d83 in cmd_make_descvec (string=0x55555555734f "multi3 (foo|bar) [(one|two|three)]", descstr=0x555555557372 "multi3 test command\nfoo\nbar\n1\n2\n3\n") at command.c:439 439 OSMO_ASSERT(multiple); (gdb) p cp $1 = 0x555555557365 "|two|three)]"
libosmocore.git 9d73503bd09eb164f781d488bf2c839c0822798a
No data to display
Actions