summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2010-01-14 21:16:55 +0000
committerWerner Koch <wk@gnupg.org>2010-01-14 21:16:55 +0000
commit4f05e4cc4e6f74d0c8273abf588636b93cccd760 (patch)
treedfce8d7998d1f0d4294dba48eab06e2c1320a9c7
parentf03ab2cc496d51a6d5457ae8e709ba68fe41c9f8 (diff)
downloadlibassuan-4f05e4cc4e6f74d0c8273abf588636b93cccd760.tar.gz
Fix NULL de-reference in debug code.
-rw-r--r--src/ChangeLog7
-rw-r--r--src/assuan.c4
-rw-r--r--src/debug.c12
3 files changed, 16 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9e0d9b4..33df124 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-14 Werner Koch <wk@g10code.com>
+
+ * debug.c (_assuan_debug, _assuan_debug_begin)
+ (_assuan_debug_buffer): Check CTX before dereferencing.
+
+ * assuan.c (assuan_release): Immediately leave on NULL CTX.
+
2010-01-05 Marcus Brinkmann <marcus@g10code.de>
* debug.h (TRACE_LOG5): Add macro.
diff --git a/src/assuan.c b/src/assuan.c
index 31263d4..21dd29d 100644
--- a/src/assuan.c
+++ b/src/assuan.c
@@ -176,11 +176,11 @@ _assuan_reset (assuan_context_t ctx)
void
assuan_release (assuan_context_t ctx)
{
- TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx);
-
if (! ctx)
return;
+ TRACE (ctx, ASSUAN_LOG_CTX, "assuan_release", ctx);
+
_assuan_reset (ctx);
/* None of the members that are our responsibility requires
deallocation. */
diff --git a/src/debug.c b/src/debug.c
index 0bdbfb5..1b654b7 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -49,7 +49,7 @@ _assuan_debug (assuan_context_t ctx, unsigned int cat, const char *format, ...)
char *msg;
int res;
- if (ctx->log_cb == NULL)
+ if (!ctx || !ctx->log_cb)
return;
saved_errno = errno;
@@ -75,8 +75,9 @@ _assuan_debug_begin (assuan_context_t ctx,
*line = NULL;
/* Probe if this wants to be logged based on category. */
- if (! ctx->log_cb ||
- ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
+ if (! ctx
+ || ! ctx->log_cb
+ || ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
return;
va_start (arg_ptr, format);
@@ -144,8 +145,9 @@ _assuan_debug_buffer (assuan_context_t ctx, unsigned int cat,
int j;
/* Probe if this wants to be logged based on category. */
- if (! ctx->log_cb ||
- ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
+ if (!ctx
+ || ! ctx->log_cb
+ || ! (*ctx->log_cb) (ctx, ctx->log_cb_data, cat, NULL))
return;
while (idx < len)