diff options
author | Werner Koch <wk@gnupg.org> | 2015-06-26 12:04:20 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2015-06-26 12:04:20 +0200 |
commit | 0da6afa864cfd68333941d6332d762c82928946c (patch) | |
tree | a3035647b585a04723c2130124e45a12fbf473a4 | |
parent | c6b131949bb6c77392af2cbbbeb8ea1bed129b79 (diff) | |
download | libassuan-0da6afa864cfd68333941d6332d762c82928946c.tar.gz |
Do not segv if NULL is passed for CTX in sendfd and receivefd.
* src/assuan-buffer.c (assuan_sendfd): Check that CTX is not NULL.
(assuan_receivefd): Ditto.
--
This change is to align the behaviour with that of assuan_send_data.
Suggested-by: Andre Heinecke.
Signed-off-by: Werner Koch <wk@gnupg.org>
-rw-r--r-- | doc/assuan.texi | 6 | ||||
-rw-r--r-- | src/assuan-buffer.c | 6 | ||||
-rw-r--r-- | src/context.c | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/doc/assuan.texi b/doc/assuan.texi index 358357c..10b309c 100644 --- a/doc/assuan.texi +++ b/doc/assuan.texi @@ -1205,8 +1205,10 @@ The descriptor must be sent before the command is issued that makes use of the descriptor. Note that calling this function with a @var{ctx} of @code{NULL} and -@var{fd} of @code{-1} can be used as a runtime test to check whether -descriptor passing is available on the platform. If it is, 0 is returned, otherwise an error with the error code @code{GPG_ERR_NOT_IMPLEMENTED}. +@var{fd} of @code{ASSUAN_INVALID_FD} can be used as a runtime test to +check whether descriptor passing is available on the platform: +@code{0} is returned if descriptor passing is available, otherwise an +error with the error code @code{GPG_ERR_NOT_IMPLEMENTED} is returned. @end deftypefun @anchor{function assuan_receivefd} diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c index 04aff5a..b442b3d 100644 --- a/src/assuan-buffer.c +++ b/src/assuan-buffer.c @@ -524,6 +524,9 @@ assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd) return _assuan_error (ctx, GPG_ERR_NOT_IMPLEMENTED); #endif + if (!ctx) + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); + if (! ctx->engine.sendfd) return set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, "server does not support sending and receiving " @@ -534,6 +537,9 @@ assuan_sendfd (assuan_context_t ctx, assuan_fd_t fd) gpg_error_t assuan_receivefd (assuan_context_t ctx, assuan_fd_t *fd) { + if (!ctx) + return _assuan_error (ctx, GPG_ERR_ASS_INV_VALUE); + if (! ctx->engine.receivefd) return set_error (ctx, GPG_ERR_NOT_IMPLEMENTED, "server does not support sending and receiving " diff --git a/src/context.c b/src/context.c index 62b7f57..147edae 100644 --- a/src/context.c +++ b/src/context.c @@ -183,8 +183,8 @@ void assuan_set_io_monitor (assuan_context_t ctx, /* Store the error in the context so that the error sending function - can take out a descriptive text. Inside the assuan code, use the - macro set_error instead of this function. */ + can take out a descriptive text. Inside the assuan code, use the + macro set_error instead of this function. */ gpg_error_t assuan_set_error (assuan_context_t ctx, gpg_error_t err, const char *text) { |