[Pkg-gnupg-commit] [libassuan] 406/437: Fix NULL deref when tracing is enabled and malloc fails.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:34:10 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 326a2918d645dd3d38dbc928e4452c66cb9757f1
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Apr 15 16:40:48 2014 +0200

    Fix NULL deref when tracing is enabled and malloc fails.
    
    * src/debug.h (TRACE_ERR): Check CTX before a deref.
    * src/assuan-defs.h (_assuan_error): Turn into an inline function and
    check CTX before a deref.
    --
    
    Found by Hans-Christoph Steiner with cppcheck.
---
 src/assuan-defs.h | 11 ++++++++---
 src/debug.h       |  8 ++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index 63329c8..364510f 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -54,9 +54,6 @@
 
 #define LINELENGTH ASSUAN_LINELENGTH
 
-/* Generate an error code specific to a context.  */
-#define _assuan_error(ctx, errcode) gpg_err_make ((ctx)->err_source, errcode)
-
 
 struct cmdtbl_s
 {
@@ -225,7 +222,15 @@ struct assuan_context_s
   assuan_fd_t output_fd;  /* Set by the OUTPUT command.  */
 };
 
+
 

+/* Generate an error code specific to a context.  */
+static GPG_ERR_INLINE gpg_error_t
+_assuan_error (assuan_context_t ctx, gpg_err_code_t errcode)
+{
+  return gpg_err_make (ctx?ctx->err_source:0, errcode);
+}
+
 /* Release all resources associated with an engine operation.  */
 void _assuan_reset (assuan_context_t ctx);
 
diff --git a/src/debug.h b/src/debug.h
index bd586c3..40f5aaa 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -1,18 +1,18 @@
 /* debug.h - interface to debugging functions
    Copyright (C) 2002, 2004, 2005, 2007 g10 Code GmbH
- 
+
    This file is part of Assuan.
 
    Assuan is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.
-   
+
    Assuan is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
-   
+
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -170,7 +170,7 @@ void _assuan_debug_buffer (assuan_context_t ctx, unsigned int cat,
 		    "%s (%s=%p): error: %s <%s>\n",			\
 		    _assuan_trace_func, _assuan_trace_tagname,		\
 		    _assuan_trace_tag, gpg_strerror (err),		\
-		    gpg_strsource (ctx->err_source)),			\
+		    ctx?gpg_strsource (ctx->err_source):""),            \
      _assuan_error (ctx, err))
 
 /* The cast to void suppresses GCC warnings.  */

-- 
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