]> 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)
committerKevin Harwell <kharwell@digium.com>
Fri, 1 Jul 2022 15:14:55 +0000 (10:14 -0500)
commit12f693d4015d5dcfb89fb464cdc25833eaeb242b
tree95e0c7c066b303e92d4cd7b5b64267c93a7ff7a4
parent2a8d4079358cdd9611fa58dac8f6ccb96f57da1a
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