[svn] GnuPG - r4816 - trunk/common

svn author wk cvs at cvs.gnupg.org
Tue Aug 19 21:36:43 CEST 2008


Author: wk
Date: 2008-08-19 21:36:42 +0200 (Tue, 19 Aug 2008)
New Revision: 4816

Modified:
   trunk/common/ChangeLog
   trunk/common/iobuf.c
Log:
Avoid passing NULL to printf while debugging.


Modified: trunk/common/ChangeLog
===================================================================
--- trunk/common/ChangeLog	2008-08-19 19:36:04 UTC (rev 4815)
+++ trunk/common/ChangeLog	2008-08-19 19:36:42 UTC (rev 4816)
@@ -1,3 +1,9 @@
+2008-08-19  Werner Koch  <wk at g10code.com>
+
+	* iobuf.c: Avoid passing a NULL (iobuf_t)->desc to the log
+	function.  Should in general never be NULL, but well.  Reported by
+	M. Heneka.
+
 2008-06-26  Werner Koch  <wk at g10code.com>
 
 	* estream.c (es_write_sanitized): Loose check for control

Modified: trunk/common/iobuf.c
===================================================================
--- trunk/common/iobuf.c	2008-08-19 19:36:04 UTC (rev 4815)
+++ trunk/common/iobuf.c	2008-08-19 19:36:42 UTC (rev 4816)
@@ -1,6 +1,6 @@
 /* iobuf.c  -  File Handling for OpenPGP.
  * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2006,
- *               2007  Free Software Foundation, Inc.
+ *               2007, 2008  Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
@@ -78,7 +78,7 @@
      we are using the low-evel backend.
 
    fp_or_fd_t
-     Is the type we use for the backend stream or fiel descriptor.
+     Is the type we use for the backend stream or file descriptor.
 
    INVALID_FP, FILEP_OR_FD_FOR_STDIN, FILEP_OR_FD_FOR_STDOUT
      Are macros defined depending on the used backend.
@@ -1012,7 +1012,7 @@
 		   (byte *) & desc, &dummy_len);
 
       log_debug ("iobuf chain: %d.%d `%s' filter_eof=%d start=%d len=%d\n",
-		 a->no, a->subno, desc, a->filter_eof,
+		 a->no, a->subno, desc?desc:"?", a->filter_eof,
 		 (int) a->d.start, (int) a->d.len);
     }
 }
@@ -1069,7 +1069,8 @@
 	log_error ("iobuf_flush failed on close: %s\n", gpg_strerror (rc));
 
       if (DBG_IOBUF)
-	log_debug ("iobuf-%d.%d: close `%s'\n", a->no, a->subno, a->desc);
+	log_debug ("iobuf-%d.%d: close `%s'\n", a->no, a->subno,
+                   a->desc?a->desc:"?");
       if (a->filter && (rc = a->filter (a->filter_ov, IOBUFCTRL_FREE,
 					a->chain, NULL, &dummy_len)))
 	log_error ("IOBUFCTRL_FREE failed on close: %s\n", gpg_strerror (rc));
@@ -1336,7 +1337,8 @@
   file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len);
   file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
   if (DBG_IOBUF)
-    log_debug ("iobuf-%d.%d: create `%s'\n", a->no, a->subno, a->desc);
+    log_debug ("iobuf-%d.%d: create `%s'\n", a->no, a->subno,
+               a->desc?a->desc:"?");
 
   return a;
 }
@@ -1369,7 +1371,8 @@
   file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len);
   file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
   if (DBG_IOBUF)
-    log_debug ("iobuf-%d.%d: append `%s'\n", a->no, a->subno, a->desc);
+    log_debug ("iobuf-%d.%d: append `%s'\n", a->no, a->subno,
+               a->desc?a->desc:"?");
 
   return a;
 }
@@ -1397,7 +1400,8 @@
   file_filter (fcx, IOBUFCTRL_DESC, NULL, (byte *) & a->desc, &len);
   file_filter (fcx, IOBUFCTRL_INIT, NULL, NULL, &len);
   if (DBG_IOBUF)
-    log_debug ("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno, a->desc);
+    log_debug ("iobuf-%d.%d: openrw `%s'\n", a->no, a->subno,
+               a->desc?a->desc:"?");
 
   return a;
 }
@@ -1410,7 +1414,8 @@
     {				/* keep system filepointer/descriptor open */
       if (DBG_IOBUF)
 	log_debug ("iobuf-%d.%d: ioctl `%s' keep=%d\n",
-		   a ? a->no : -1, a ? a->subno : -1, a ? a->desc : "?",
+		   a ? a->no : -1, a ? a->subno : -1, 
+                   a && a->desc ? a->desc : "?",
 		   intval);
       for (; a; a = a->chain)
 	if (!a->chain && a->filter == file_filter)
@@ -1445,7 +1450,8 @@
     {				/* disallow/allow caching */
       if (DBG_IOBUF)
 	log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n",
-		   a ? a->no : -1, a ? a->subno : -1, a ? a->desc : "?",
+		   a ? a->no : -1, a ? a->subno : -1, 
+                   a && a->desc? a->desc : "?",
 		   intval);
       for (; a; a = a->chain)
 	if (!a->chain && a->filter == file_filter)
@@ -1546,7 +1552,8 @@
 
   if (DBG_IOBUF)
     {
-      log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno, a->desc);
+      log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno, 
+                 a->desc?a->desc:"?");
       print_chain (a);
     }
 
@@ -1573,7 +1580,8 @@
     BUG ();
 
   if (DBG_IOBUF)
-    log_debug ("iobuf-%d.%d: pop `%s'\n", a->no, a->subno, a->desc);
+    log_debug ("iobuf-%d.%d: pop `%s'\n", a->no, a->subno,
+               a->desc?a->desc:"?");
   if (!a->filter)
     {				/* this is simple */
       b = a->chain;
@@ -1660,7 +1668,7 @@
 	  iobuf_t b = a->chain;
 	  if (DBG_IOBUF)
 	    log_debug ("iobuf-%d.%d: pop `%s' in underflow\n",
-		       a->no, a->subno, a->desc);
+		       a->no, a->subno, a->desc?a->desc:"?");
 	  xfree (a->d.buf);
 	  xfree (a->real_fname);
 	  memcpy (a, b, sizeof *a);
@@ -1733,8 +1741,8 @@
 	    {
 	      iobuf_t b = a->chain;
 	      if (DBG_IOBUF)
-		log_debug ("iobuf-%d.%d: pop `%s' in underflow (!len)\n",
-			   a->no, a->subno, a->desc);
+		log_debug ("iobuf-%d.%d: pop in underflow (!len)\n",
+			   a->no, a->subno);
 	      xfree (a->d.buf);
 	      xfree (a->real_fname);
 	      memcpy (a, b, sizeof *a);




More information about the Gnupg-commits mailing list