diff options
| author | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2017-05-22 00:29:59 +0300 |
|---|---|---|
| committer | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2017-05-22 00:29:59 +0300 |
| commit | f63d2754e38e718638bb4262df187109cfa2a204 (patch) | |
| tree | f87fe9050100a9b5d5f22fdd4a6c0082d0ca0430 /libguile-ssh | |
| parent | channel-type.c (print_channel): Bugfix: Handle freed channels (diff) | |
| download | guile-ssh-f63d2754e38e718638bb4262df187109cfa2a204.tar.gz | |
channel-func.c (guile_ssh_channel_get_exit_status): Handle freed channels
* libguile-ssh/channel-func.c (guile_ssh_channel_get_exit_status): Throw
'wrong-type-arg' if a freed channel is passed as an argument.
* libguile-ssh/channel-type.h (GSSH_VALIDATE_OPEN_CHANNEL): Check if a channel
is freed.
* tests/client-server.scm ("channel-get-exit-status, freed channel"): New test
case.
* tests/common.scm (test-error-with-log/=): Check error key and message
properly.
(test-error-with-log): Check an error key.
(test-error-with-log/handler): Remove extra rules.
* NEWS: Update.
Diffstat (limited to 'libguile-ssh')
| -rw-r--r-- | libguile-ssh/channel-func.c | 3 | ||||
| -rw-r--r-- | libguile-ssh/channel-type.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/libguile-ssh/channel-func.c b/libguile-ssh/channel-func.c index f657102..4e2980f 100644 --- a/libguile-ssh/channel-func.c +++ b/libguile-ssh/channel-func.c @@ -101,11 +101,12 @@ returned (yet). \ ") #define FUNC_NAME s_guile_ssh_channel_get_exit_status { - struct channel_data *cd = _scm_to_channel_data (channel); + struct channel_data *cd = NULL; int res; GSSH_VALIDATE_OPEN_CHANNEL (channel, SCM_ARG1, FUNC_NAME); + cd = _scm_to_channel_data (channel); res = ssh_channel_get_exit_status (cd->ssh_channel); if (res == SSH_ERROR) { _gssh_log_warning (FUNC_NAME, diff --git a/libguile-ssh/channel-type.h b/libguile-ssh/channel-type.h index 72bd16b..2584dde 100644 --- a/libguile-ssh/channel-type.h +++ b/libguile-ssh/channel-type.h @@ -44,6 +44,8 @@ struct channel_data { /* Make sure that the channel SCM is open. */ #define GSSH_VALIDATE_OPEN_CHANNEL(scm, pos, fn) \ do { \ + if (! SCM_PTAB_ENTRY (channel)) \ + scm_wrong_type_arg_msg (fn, pos, scm, "open channel"); \ SCM_ASSERT_TYPE (SCM_OPPORTP (scm), scm, pos, fn, "open channel"); \ } while (0) |
