mirror of https://gerrit.osmocom.org/libosmocore
5314c513f2
vty_test: add test against ambiguous cmd causing use-after-free and memory leaks. Add this test along with the fix, because the new test triggers the memory use-after-free and leaks, causing build failures. Add cmd_deopt_with_ctx() to allow passing a specific talloc ctx. is_cmd_ambiguous(): keep all cmd_deopt() allocations until the function exits. Add a comment explaining why. Before this, if a command matched an optional "[arg]" with square brackets, we would keep it in local var 'matched', but we would free the string it points to at the end of that loop iteration; upon encountering another match, we would attempt to strcmp against the freed 'matched'. Instead of adding hard-to-read and -verify free/alloc dances to keep the 'matched' accurately freed/non-freed/..., just keep all cmd_deopt() string allocated until done. Needless to say that this should have been implemented on a lower level upon inventing optional args, but at least this is fixing a program crash. Related: OS#33903390 Change-Id: Ia71ba742108b5ff020997bfb612ad5eb30d04fcd |
||
---|---|---|
.. | ||
fail_not_de-indented.cfg | ||
fail_tabs_and_spaces.cfg | ||
fail_too_much_indent.cfg | ||
ok.cfg | ||
ok_empty_parent.cfg | ||
ok_ignore_blank.cfg | ||
ok_ignore_comment.cfg | ||
ok_indented_root.cfg | ||
ok_more_spaces.cfg | ||
ok_tabs.cfg | ||
ok_tabs_and_spaces.cfg | ||
vty_test.c | ||
vty_test.ok |