[Pkg-gnupg-commit] [libassuan] 292/437: Fix NULL de-reference in debug code.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit 4f05e4cc4e6f74d0c8273abf588636b93cccd760
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jan 14 21:16:55 2010 +0000

    Fix NULL de-reference in debug code.
---
 src/ChangeLog |  7 +++++++
 src/assuan.c  |  4 ++--
 src/debug.c   | 12 +++++++-----
 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 at 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 at 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)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list