[git] GnuPG - branch, master, updated. post-nuke-of-trailing-ws-28-gaeb3242

by Werner Koch cvs at cvs.gnupg.org
Thu Mar 3 15:24:08 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  aeb324273afdb1999e2b3ea3471fe28856a6d3b1 (commit)
       via  ea41f5b4c19dade3a89d486ce1c2530ac11226cc (commit)
       via  892793888e3b328bff032b0b3e8b5098ffeb9b7f (commit)
      from  682da55aa985afcbae3b16686ad96bb77ad87adf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit aeb324273afdb1999e2b3ea3471fe28856a6d3b1
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Mar 3 12:57:31 2011 +0100

    Minor code cleanups.
    
    	* keyid.c (hash_public_key): Remove shadowing NBITS.
    
    	* misc.c (pubkey_nbits): Replace GCRY_PK_ by PUBKEY_ALGO_.
    	(get_signature_count): Remove warning.

diff --git a/g10/ChangeLog b/g10/ChangeLog
index cdacc6f..df424a3 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,5 +1,10 @@
 2011-03-03  Werner Koch  <wk at g10code.com>
 
+	* keyid.c (hash_public_key): Remove shadowing NBITS.
+
+	* misc.c (pubkey_nbits): Replace GCRY_PK_ by PUBKEY_ALGO_.
+	(get_signature_count): Remove warning.
+
 	* armor.c (armor_filter): Don't take a copy of radbuf while
 	writing the checksum.  This works around a faulty gcc 4.4 warning.
 
diff --git a/g10/keyid.c b/g10/keyid.c
index cbcc971..d08ccee 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -99,7 +99,6 @@ hash_public_key (gcry_md_hd_t md, PKT_public_key *pk)
         {
           if (gcry_mpi_get_flag (pk->pkey[i], GCRYMPI_FLAG_OPAQUE))
             {
-              size_t nbits;
               const void *p;
 
               p = gcry_mpi_get_opaque (pk->pkey[i], &nbits);
diff --git a/g10/misc.c b/g10/misc.c
index f2ab984..e0c57a1 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -569,7 +569,8 @@ get_signature_count (PKT_public_key *pk)
 {
 #ifdef ENABLE_CARD_SUPPORT
   struct agent_card_info_s info;
-#warning fixme: We should check that the correct card has been inserted
+
+  (void)pk;
   if (!agent_scd_getattr ("SIG-COUNTER",&info))
     return info.sig_counter;
   else
@@ -1453,20 +1454,17 @@ pubkey_nbits( int algo, gcry_mpi_t *key )
     int rc, nbits;
     gcry_sexp_t sexp;
 
-#warning FIXME:  We are mixing OpenPGP And CGrypt Ids
-    assert( algo != GCRY_PK_ECDSA && algo != GCRY_PK_ECDH );
-
-    if( algo == GCRY_PK_DSA ) {
+    if( algo == PUBKEY_ALGO_DSA ) {
 	rc = gcry_sexp_build ( &sexp, NULL,
 			      "(public-key(dsa(p%m)(q%m)(g%m)(y%m)))",
 				  key[0], key[1], key[2], key[3] );
     }
-    else if( algo == GCRY_PK_ELG || algo == GCRY_PK_ELG_E ) {
+    else if( algo == PUBKEY_ALGO_ELGAMAL || algo == PUBKEY_ALGO_ELGAMAL_E ) {
 	rc = gcry_sexp_build ( &sexp, NULL,
 			      "(public-key(elg(p%m)(g%m)(y%m)))",
 				  key[0], key[1], key[2] );
     }
-    else if( algo == GCRY_PK_RSA ) {
+    else if( is_RSA (algo) ) {
 	rc = gcry_sexp_build ( &sexp, NULL,
 			      "(public-key(rsa(n%m)(e%m)))",
 				  key[0], key[1] );

commit ea41f5b4c19dade3a89d486ce1c2530ac11226cc
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Mar 3 12:40:54 2011 +0100

    Fix faulty gcc warnings

diff --git a/g10/ChangeLog b/g10/ChangeLog
index 65e97a9..cdacc6f 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-03  Werner Koch  <wk at g10code.com>
+
+	* armor.c (armor_filter): Don't take a copy of radbuf while
+	writing the checksum.  This works around a faulty gcc 4.4 warning.
+
 2011-03-02  Werner Koch  <wk at g10code.com>
 
 	* call-agent.c (agent_scd_pksign, agent_scd_pkdecrypt)
diff --git a/g10/armor.c b/g10/armor.c
index 3948916..43ebb2e 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -1182,21 +1182,20 @@ armor_filter( void *opaque, int control,
 	    crc = afx->crc;
 	    idx = afx->idx;
 	    idx2 = afx->idx2;
-	    for(i=0; i < idx; i++ )
-		radbuf[i] = afx->radbuf[i];
 	    if( idx ) {
-		c = bintoasc[(*radbuf>>2)&077];
+		c = bintoasc[(afx->radbuf[0]>>2)&077];
 		iobuf_put(a, c);
 		if( idx == 1 ) {
-		    c = bintoasc[((*radbuf << 4) & 060) & 077];
+		    c = bintoasc[((afx->radbuf[0] << 4) & 060) & 077];
 		    iobuf_put(a, c);
 		    iobuf_put(a, '=');
 		    iobuf_put(a, '=');
 		}
 		else { /* 2 */
-		    c = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077];
+		    c = bintoasc[(((afx->radbuf[0]<<4)&060)
+                                  |((afx->radbuf[1]>>4)&017))&077];
 		    iobuf_put(a, c);
-		    c = bintoasc[((radbuf[1] << 2) & 074) & 077];
+		    c = bintoasc[((afx->radbuf[1] << 2) & 074) & 077];
 		    iobuf_put(a, c);
 		    iobuf_put(a, '=');
 		}
diff --git a/sm/ChangeLog b/sm/ChangeLog
index 44e4eb3..dc5989a 100644
--- a/sm/ChangeLog
+++ b/sm/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-03  Werner Koch  <wk at g10code.com>
+
+	* base64.c (base64_finish_write): Do not copy to radbuf to get rid
+	of a faulty gcc 4.4 "used uninitialized" warning.
+
 2011-03-01  Werner Koch  <wk at g10code.com>
 
 	* certreqgen.c (pSERIAL, pISSUERDN, pNOTBEFORE, pNOTAFTER)
diff --git a/sm/base64.c b/sm/base64.c
index 1539e2a..4a67d61 100644
--- a/sm/base64.c
+++ b/sm/base64.c
@@ -484,8 +484,8 @@ plain_writer_cb (void *cb_value, const void *buffer, size_t count)
 static int
 base64_finish_write (struct writer_cb_parm_s *parm)
 {
-  unsigned char radbuf[4];
-  int i, c, idx, quad_count;
+  unsigned char *radbuf;
+  int c, idx, quad_count;
   estream_t stream = parm->stream;
 
   if (!parm->wrote_begin)
@@ -494,11 +494,10 @@ base64_finish_write (struct writer_cb_parm_s *parm)
   /* flush the base64 encoding */
   idx = parm->base64.idx;
   quad_count = parm->base64.quad_count;
-  for (i=0; i < idx; i++)
-    radbuf[i] = parm->base64.radbuf[i];
-
   if (idx)
     {
+      radbuf = parm->base64.radbuf;
+
       c = bintoasc[(*radbuf>>2)&077];
       es_putc (c, stream);
       if (idx == 1)
diff --git a/tools/no-libgcrypt.c b/tools/no-libgcrypt.c
index 4967576..9e52566 100644
--- a/tools/no-libgcrypt.c
+++ b/tools/no-libgcrypt.c
@@ -157,5 +157,6 @@ gcry_create_nonce (void *buffer, size_t length)
 const char *
 gcry_cipher_algo_name (int algo)
 {
+  (void)algo;
   return "?";
 }

commit 892793888e3b328bff032b0b3e8b5098ffeb9b7f
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Mar 3 11:51:04 2011 +0100

    Simplify the management of the stream list in estream.c

diff --git a/common/ChangeLog b/common/ChangeLog
index cebc0ec..6253867 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,14 @@
+2011-03-03  Werner Koch  <wk at g10code.com>
+
+	* estream.c (struct estream_list): Rename to estream_list_s and
+	simplify.  A double linked list is overkill for our purpose.
+	(do_list_add, do_list_remove): Adjust accordingly.
+	(_es_get_std_stream): Ditto.
+	(do_list_iterate, estream_iterator_t): Remove; it is used only at
+	one place.
+	(es_fflush): Replace iteration function.  Also lock each stream
+	while flushing all streams.
+
 2011-02-27  Werner Koch  <wk at g10code.com>
 
 	* gettime.c (isotime2epoch): Factor check code out to ..
diff --git a/common/estream.c b/common/estream.c
index a73d1f2..5b55674 100644
--- a/common/estream.c
+++ b/common/estream.c
@@ -1,5 +1,5 @@
 /* estream.c - Extended Stream I/O Library
- * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 g10 Code GmbH
+ * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 g10 Code GmbH
  *
  * This file is part of Libestream.
  *
@@ -254,28 +254,26 @@ typedef struct estream_internal *estream_internal_t;
 #define ESTREAM_UNLOCK(stream) ESTREAM_MUTEX_UNLOCK (stream->intern->lock)
 #define ESTREAM_TRYLOCK(stream) ESTREAM_MUTEX_TRYLOCK (stream->intern->lock)
 
-/* Stream list.  */
-
-typedef struct estream_list *estream_list_t;
-
-struct estream_list
+/* A linked list to hold active stream objects.   */
+struct estream_list_s
 {
-  estream_t car;
-  estream_list_t cdr;
-  estream_list_t *prev_cdr;
+  struct estream_list_s *next;
+  estream_t stream;  /* Entry is not used if NULL.  */
 };
-
+typedef struct estream_list_s *estream_list_t;
 static estream_list_t estream_list;
-static estream_mutex_t estream_list_lock;
-
-#define ESTREAM_LIST_LOCK   ESTREAM_MUTEX_LOCK   (estream_list_lock)
-#define ESTREAM_LIST_UNLOCK ESTREAM_MUTEX_UNLOCK (estream_list_lock)
 
 /* File descriptors registered to be used as the standard file handles. */
 static int custom_std_fds[3];
 static unsigned char custom_std_fds_valid[3];
 
+/* A lock object for the estream list and the custom_std_fds array.  */
+static estream_mutex_t estream_list_lock;
+#define ESTREAM_LIST_LOCK   ESTREAM_MUTEX_LOCK   (estream_list_lock)
+#define ESTREAM_LIST_UNLOCK ESTREAM_MUTEX_UNLOCK (estream_list_lock)
+
 
+/* Error code replacements.  */
 #ifndef EOPNOTSUPP
 # define EOPNOTSUPP ENOSYS
 #endif
@@ -372,75 +370,63 @@ map_w32_to_errno (DWORD w32_err)
  */
 
 /* Add STREAM to the list of registered stream objects.  If
-   WITH_LOCKED_LIST is true we assumed that the list of streams is
-   already locked.  */
+   WITH_LOCKED_LIST is true it is assumed that the list of streams is
+   already locked.  The implementation is straightforward: We first
+   look for an unused entry in the list and use that; if none is
+   available we put a new item at the head.  We drawback of the
+   strategy never to shorten the list is that a one time allocation of
+   many streams will lead to scanning unused entries later.  If that
+   turns out to be a problem, we may either free some items from the
+   list or append new entries at the end; or use a table.  Returns 0
+   on success; on error or non-zero is returned and ERRNO set.  */
 static int
 do_list_add (estream_t stream, int with_locked_list)
 {
-  estream_list_t list_obj;
-  int ret;
+  estream_list_t item;
 
-  list_obj = mem_alloc (sizeof (*list_obj));
-  if (! list_obj)
-    ret = -1;
-  else
+  if (!with_locked_list)
+    ESTREAM_LIST_LOCK;
+
+  for (item = estream_list; item && item->stream; item = item->next)
+    ;
+  if (!item)
     {
-      if (!with_locked_list)
-        ESTREAM_LIST_LOCK;
-      list_obj->car = stream;
-      list_obj->cdr = estream_list;
-      list_obj->prev_cdr = &estream_list;
-      if (estream_list)
-	estream_list->prev_cdr = &list_obj->cdr;
-      estream_list = list_obj;
-      if (!with_locked_list)
-        ESTREAM_LIST_UNLOCK;
-      ret = 0;
+      item = mem_alloc (sizeof *item);
+      if (item)
+        {
+          item->next = estream_list;
+          estream_list = item;
+        }
     }
+  if (item)
+    item->stream = stream;
 
-  return ret;
+  if (!with_locked_list)
+    ESTREAM_LIST_UNLOCK;
+
+  return item? 0 : -1;
 }
 
 /* Remove STREAM from the list of registered stream objects.  */
 static void
 do_list_remove (estream_t stream, int with_locked_list)
 {
-  estream_list_t list_obj;
+  estream_list_t item;
 
   if (!with_locked_list)
     ESTREAM_LIST_LOCK;
-  for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr)
-    if (list_obj->car == stream)
+
+  for (item = estream_list; item; item = item->next)
+    if (item->stream == stream)
       {
-	*list_obj->prev_cdr = list_obj->cdr;
-	if (list_obj->cdr)
-	  list_obj->cdr->prev_cdr = list_obj->prev_cdr;
-	mem_free (list_obj);
-	break;
+        item->stream = NULL;
+        break;
       }
+
   if (!with_locked_list)
     ESTREAM_LIST_UNLOCK;
 }
 
-/* Type of an stream-iterator-function.  */
-typedef int (*estream_iterator_t) (estream_t stream);
-
-/* Iterate over list of registered streams, calling ITERATOR for each
-   of them.  */
-static int
-do_list_iterate (estream_iterator_t iterator)
-{
-  estream_list_t list_obj;
-  int ret = 0;
-
-  ESTREAM_LIST_LOCK;
-  for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr)
-    ret |= (*iterator) (list_obj->car);
-  ESTREAM_LIST_UNLOCK;
-
-  return ret;
-}
-
 
 
 /*
@@ -487,6 +473,14 @@ do_deinit (void)
 {
   /* Flush all streams. */
   es_fflush (NULL);
+
+  /* We should release the estream_list.  However there is one
+     problem: That list is also used to search for the standard
+     estream file descriptors.  If we would remove the entire list,
+     any use of es_foo in another atexit function may re-create the
+     list and the streams with possible undesirable effects.  Given
+     that we don't close the stream either, it should not matter that
+     we keep the list and let the OS clean it up at process end.  */
 }
 
 
@@ -2905,11 +2899,11 @@ _es_get_std_stream (int fd)
 
   fd %= 3; /* We only allow 0, 1 or 2 but we don't want to return an error. */
   ESTREAM_LIST_LOCK;
-  for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr)
-    if (list_obj->car->intern->is_stdstream
-        && list_obj->car->intern->stdstream_fd == fd)
+  for (list_obj = estream_list; list_obj; list_obj = list_obj->next)
+    if (list_obj->stream && list_obj->stream->intern->is_stdstream
+        && list_obj->stream->intern->stdstream_fd == fd)
       {
-	stream = list_obj->car;
+	stream = list_obj->stream;
 	break;
       }
   if (!stream)
@@ -3241,8 +3235,20 @@ es_fflush (estream_t stream)
       ESTREAM_UNLOCK (stream);
     }
   else
-    err = do_list_iterate (do_fflush);
+    {
+      estream_list_t item;
 
+      err = 0;
+      ESTREAM_LIST_LOCK;
+      for (item = estream_list; item; item = item->next)
+        if (item->stream)
+          {
+            ESTREAM_LOCK (item->stream);
+            err |= do_fflush (item->stream);
+            ESTREAM_UNLOCK (item->stream);
+          }
+      ESTREAM_LIST_UNLOCK;
+    }
   return err ? EOF : 0;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 common/ChangeLog     |   11 ++++
 common/estream.c     |  138 ++++++++++++++++++++++++++------------------------
 g10/ChangeLog        |   10 ++++
 g10/armor.c          |   11 ++--
 g10/keyid.c          |    1 -
 g10/misc.c           |   12 ++---
 sm/ChangeLog         |    5 ++
 sm/base64.c          |    9 ++--
 tools/no-libgcrypt.c |    1 +
 9 files changed, 113 insertions(+), 85 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list