diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-06-14 17:41:04 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-06-15 10:05:57 +0200 |
commit | 2e181f9c4d655bcf4c65b048e72e4232377df97c (patch) | |
tree | 52fb7ea9f5aab6e7c2af7a91efff0d06acc44749 | |
parent | 9819ffe7d42f08bb082ae2d9e125a7dd3bfe6420 (diff) | |
download | NetworkManager-2e181f9c4d655bcf4c65b048e72e4232377df97c.tar.gz |
cli: fix failed assertion in readline helper
The INT signal can arrive after a new line has been processed in
nmc_readline_helper(). In such case, the handler gets uninstalled by
readline_cb() and nmc_seen_sigint() returns TRUE. However it's an
error to call rl_callback_read_char() without handler, don't do it.
Fixes the following:
"readline: readline_callback_read_char() called with no handler!"
#0 __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1 __GI_abort () at abort.c:90
#2 rl_callback_read_char () at ../callback.c:116
#3 nmc_readline_helper (prompt=prompt@entry=0x2aa0d229080 "nmcli> ") at clients/cli/common.c:1387
#4 nmc_readline (prompt_fmt=prompt_fmt@entry=0x2aa0036ac9e "%s") at clients/cli/common.c:1448
#5 do_connection_edit (connection=0x2aa0d215440, nmc=0x2aa00391298 <nm_cli>) at clients/cli/connections.c:7072
Fixes: 995229181cac66c1ac5a2d63120ffbbe3ac136b0
https://bugzilla.redhat.com/show_bug.cgi?id=1458311
(cherry picked from commit cd3a56125140ccd2224b7b56669965f40cfeeae8)
-rw-r--r-- | clients/cli/common.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clients/cli/common.c b/clients/cli/common.c index 4d89c3f86b..27477166b8 100644 --- a/clients/cli/common.c +++ b/clients/cli/common.c @@ -1383,8 +1383,10 @@ read_again: /* If Ctrl-C was detected, complete the line */ if (nmc_seen_sigint ()) { rl_echo_signal_char (SIGINT); - rl_stuff_char ('\n'); - rl_callback_read_char (); + if (!rl_got_line) { + rl_stuff_char ('\n'); + rl_callback_read_char (); + } } /* Add string to the history */ |