]> git.ipfire.org Git - thirdparty/asterisk.git/commit
cli: Fix CLI blocking forever on terminating backslash
authorNaveen Albert <asterisk@phreaknet.org>
Sat, 5 Feb 2022 21:16:27 +0000 (21:16 +0000)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Thu, 30 Jun 2022 23:28:48 +0000 (18:28 -0500)
commit5b730d0bc8438d60a51902ee8ad6a6ddd7f854bf
tree580f8bd76ba3106b0e78a3cd720f5c16e869df43
parent90b403adeeaf4f561decc1b759a9077b7e0a6481
cli: Fix CLI blocking forever on terminating backslash

A corner case exists in CLI parsing where if
a CLI user in a remote console ends with
a backslash and then invokes command completion
(using TAB or ?), then the console will freeze
forever until a SIGQUIT signal is sent to the
process, due to getting blocked forever
reading the command completion. CTRL+C
and other key combinations have no impact on
the CLI session.

This occurs because, in such cases, the CLI
process is waiting for AST_CLI_COMPLETE_EOF
to appear in the buffer from the main process,
but instead the main process is confused by
the funny syntax and thus prints out the CLI help.
As a result, the CLI process is stuck on the
read call, waiting for the completion that
will never come.

This prevents blocking forever by checking
if the data from the main process starts with
"Usage:". If it does, that means that CLI help
was sent instead of the tab complete vector,
and thus the CLI should bail out and not wait
any longer.

ASTERISK-29822 #close

Change-Id: I9810ac59304fec162da701653c9c834f0ec8f670
main/asterisk.c