[git] GnuPG - branch, master, updated. post-nuke-of-trailing-ws-99-g6cf8890

by Werner Koch cvs at cvs.gnupg.org
Tue Sep 20 20:09:43 CEST 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  6cf8890dc1f551a1e87ed8b8e67a733e95b1bb6d (commit)
       via  850f09b2e30c58e338ca621e459c148650a4caa2 (commit)
       via  b8b4d5c9e55c73b2a2f0f3b5aee292de2bb0b512 (commit)
      from  7c000f18de5e7f94adc1364a2a56c99cfb23d8f8 (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 6cf8890dc1f551a1e87ed8b8e67a733e95b1bb6d
Author: Werner Koch <wk at gnupg.org>
Date:   Tue Sep 20 19:24:52 2011 +0200

    Allow NULL for free_public_key.

diff --git a/g10/ChangeLog b/g10/ChangeLog
index 8ae5747..be13196 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,14 @@
+2011-09-20  Werner Koch  <wk at g10code.com>
+
+	* free-packet.c (free_public_key): Allow a NULL argument.
+	* keyedit.c (keyedit_passwd): No more need to check that PK is NULL.
+	(menu_addrevoker): Ditto.
+	* passphrase.c (passphrase_get, passphrase_to_dek_ext): Ditto.
+	* skclist.c (release_sk_list): Ditto.
+	* revoke.c (gen_desig_revoke): Ditto.
+	* pubkey-enc.c (get_session_key): Ditto.
+	* pkclist.c (build_pk_list): Ditto.
+
 2011-09-20  Jim Meyering  <meyering at redhat.com>
 
 	avoid use of freed pointer
diff --git a/g10/free-packet.c b/g10/free-packet.c
index 2675684..5963221 100644
--- a/g10/free-packet.c
+++ b/g10/free-packet.c
@@ -120,11 +120,16 @@ release_public_key_parts (PKT_public_key *pk)
 }
 
 
+/* Free an allocated public key structure including all parts.
+   Passing NULL is allowed.  */
 void
 free_public_key (PKT_public_key *pk)
 {
-  release_public_key_parts (pk);
-  xfree(pk);
+  if (pk)
+    {
+      release_public_key_parts (pk);
+      xfree(pk);
+    }
 }
 
 
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 62b193a..fd42439 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -2253,8 +2253,7 @@ keyedit_passwd (ctrl_t ctrl, const char *username)
 
 leave:
   release_kbnode (keyblock);
-  if (pk)
-    free_public_key (pk);
+  free_public_key (pk);
   if (err)
     {
       log_info ("error changing the passphrase for `%s': %s\n",
@@ -3327,9 +3326,7 @@ menu_addrevoker (ctrl_t ctrl, kbnode_t pub_keyblock, int sensitive)
     {
       char *answer;
 
-      if (revoker_pk)
-	free_public_key (revoker_pk);
-
+      free_public_key (revoker_pk);
       revoker_pk = xmalloc_clear (sizeof (*revoker_pk));
 
       tty_printf ("\n");
@@ -3453,8 +3450,7 @@ menu_addrevoker (ctrl_t ctrl, kbnode_t pub_keyblock, int sensitive)
 fail:
   if (sig)
     free_seckey_enc (sig);
-  if (revoker_pk)
-    free_public_key (revoker_pk);
+  free_public_key (revoker_pk);
 
   return 0;
 }
diff --git a/g10/passphrase.c b/g10/passphrase.c
index 481d29e..cc56555 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -235,8 +235,7 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
   memset (fpr, 0, MAX_FINGERPRINT_LEN );
   if( keyid && get_pubkey( pk, keyid ) )
     {
-      if (pk)
-        free_public_key( pk );
+      free_public_key (pk);
       pk = NULL; /* oops: no key for some reason */
     }
 
@@ -344,8 +343,7 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
       write_status_errcode ("get_passphrase", rc);
     }
 
-  if (pk)
-    free_public_key( pk );
+  free_public_key (pk);
   if (rc)
     {
       xfree (pw);
@@ -531,8 +529,7 @@ passphrase_to_dek_ext (u32 *keyid, int pubkey_algo,
 	}
 
       tty_printf("\n");
-      if (pk)
-        free_public_key( pk );
+      free_public_key (pk);
     }
 
   if ( next_pw )
diff --git a/g10/pkclist.c b/g10/pkclist.c
index 626250f..295ee06 100644
--- a/g10/pkclist.c
+++ b/g10/pkclist.c
@@ -1064,8 +1064,7 @@ build_pk_list (ctrl_t ctrl,
             continue;
 
           /* Get and check key for the current name. */
-          if (pk)
-            free_public_key (pk);
+          free_public_key (pk);
           pk = xmalloc_clear( sizeof *pk );
           pk->req_usage = use;
           rc = get_pubkey_byname (ctrl, NULL, pk, answer, NULL, NULL, 0, 0 );
@@ -1078,7 +1077,8 @@ build_pk_list (ctrl_t ctrl,
                   /* No validation for a default recipient. */
                   if (!key_present_in_pk_list(pk_list, pk))
                     {
-                      free_public_key (pk); pk = NULL;
+                      free_public_key (pk);
+                      pk = NULL;
                       log_info (_("skipped: public key "
                                   "already set as default recipient\n") );
                     }
@@ -1108,7 +1108,8 @@ build_pk_list (ctrl_t ctrl,
                        * present in the list */
                       if (!key_present_in_pk_list(pk_list, pk))
                         {
-                          free_public_key(pk); pk = NULL;
+                          free_public_key (pk);
+                          pk = NULL;
                           log_info(_("skipped: public key already set\n") );
                         }
                       else
diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c
index 1b94af5..680182b 100644
--- a/g10/pubkey-enc.c
+++ b/g10/pubkey-enc.c
@@ -97,8 +97,7 @@ get_session_key (PKT_pubkey_enc * k, DEK * dek)
 
       for (;;)
         {
-          if (sk)
-            free_public_key (sk);
+          free_public_key (sk);
           sk = xmalloc_clear (sizeof *sk);
           rc = enum_secret_keys (&enum_context, sk);
           if (rc)
@@ -127,8 +126,7 @@ get_session_key (PKT_pubkey_enc * k, DEK * dek)
     }
 
 leave:
-  if (sk)
-    free_public_key (sk);
+  free_public_key (sk);
   return rc;
 }
 
diff --git a/g10/revoke.c b/g10/revoke.c
index 2c696cc..396b6d4 100644
--- a/g10/revoke.c
+++ b/g10/revoke.c
@@ -262,11 +262,8 @@ gen_desig_revoke( const char *uname, strlist_t locusr )
       {
 	SK_LIST list;
 
-	if (pk2)
-	  {
-	    free_public_key (pk2);
-	    pk2 = NULL;
-	  }
+        free_public_key (pk2);
+        pk2 = NULL;
 
 	if(sk_list)
 	  {
@@ -417,10 +414,8 @@ gen_desig_revoke( const char *uname, strlist_t locusr )
       log_error(_("no revocation keys found for \"%s\"\n"),uname);
 
   leave:
-    if( pk )
-	free_public_key( pk );
-    if (pk2)
-	free_public_key (pk2);
+    free_public_key (pk);
+    free_public_key (pk2);
     if( sig )
 	free_seckey_enc( sig );
 
diff --git a/g10/skclist.c b/g10/skclist.c
index 912104e..5a3ea95 100644
--- a/g10/skclist.c
+++ b/g10/skclist.c
@@ -51,8 +51,7 @@ release_sk_list (SK_LIST sk_list)
   for (; sk_list; sk_list = sk_rover)
     {
       sk_rover = sk_list->next;
-      if (sk_list->pk)
-        free_public_key (sk_list->pk);
+      free_public_key (sk_list->pk);
       xfree (sk_list);
     }
 }

commit 850f09b2e30c58e338ca621e459c148650a4caa2
Author: Jim Meyering <jim at meyering.net>
Date:   Tue Sep 20 16:35:30 2011 +0200

    tests: avoid use of freed pointer
    
    [spotted by coverity]
    
    This is only in tests/, but easy to fix, so...
    I've included extra context so you can see how var->value would
    be used in the following atoi call.
    
    >From cf9ae83fd2da8d7a289b048ef0feed4096f6d263 Mon Sep 17 00:00:00 2001
    From: Jim Meyering <meyering at redhat.com>
    Date: Tue, 20 Sep 2011 16:32:59 +0200
    Subject: [PATCH] avoid use of free'd pointer
    
    * asschk.c (set_type_var): Set var->value to NULL after freeing it,
    to avoid subsequent use of freed pointer.

diff --git a/tests/ChangeLog b/tests/ChangeLog
index b2e95f3..aa93f07 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-20  Jim Meyering  <meyering at redhat.com>
+
+	avoid use of free'd pointer
+	* asschk.c (set_type_var): Set var->value to NULL after freeing it,
+	to avoid subsequent use of freed pointer.
+
 2009-10-13  Werner Koch  <wk at g10code.com>
 
 	* asschk.c (die): Replace this vararg macro by C-89 compliant
diff --git a/tests/asschk.c b/tests/asschk.c
index 3eb2621..c0108e7 100644
--- a/tests/asschk.c
+++ b/tests/asschk.c
@@ -514,7 +514,10 @@ set_type_var (const char *name, const char *value, VARTYPE type)
       variable_list = var;
     }
   else
-    free (var->value);
+    {
+      free (var->value);
+      var->value = NULL;
+    }
 
   if (var->type == VARTYPE_FD && var->value)
     {

commit b8b4d5c9e55c73b2a2f0f3b5aee292de2bb0b512
Author: Jim Meyering <jim at meyering.net>
Date:   Tue Sep 20 16:26:37 2011 +0200

    avoid use of freed pointer
    
    Without this patch, pk2 would be freed twice.
    
    >From 2a18a4b757e0896e738fefbbaa8ff8c23a9edf89 Mon Sep 17 00:00:00 2001
    From: Jim Meyering <meyering at redhat.com>
    Date: Tue, 20 Sep 2011 16:20:39 +0200
    Subject: [PATCH] avoid use of freed pointer
    
    If we free pk2 at the top of the for-loop, set it to NULL
    so that we don't free it again just before returning.
    * revoke.c (gen_desig_revoke): Don't use pk2 after freeing it.

diff --git a/g10/ChangeLog b/g10/ChangeLog
index be2ad0b..8ae5747 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-20  Jim Meyering  <meyering at redhat.com>
+
+	avoid use of freed pointer
+	If we free pk2 at the top of the for-loop, set it to NULL
+	so that we don't free it again just before returning.
+	* revoke.c (gen_desig_revoke): Don't use pk2 after freeing it.
+
 2011-09-20  Werner Koch  <wk at g10code.com>
 
 	* sign.c (sign_file, clearsign_file, sign_symencrypt_file):
diff --git a/g10/revoke.c b/g10/revoke.c
index c18dfb9..2c696cc 100644
--- a/g10/revoke.c
+++ b/g10/revoke.c
@@ -263,7 +263,10 @@ gen_desig_revoke( const char *uname, strlist_t locusr )
 	SK_LIST list;
 
 	if (pk2)
-	  free_public_key (pk2);
+	  {
+	    free_public_key (pk2);
+	    pk2 = NULL;
+	  }
 
 	if(sk_list)
 	  {

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

Summary of changes:
 g10/ChangeLog     |   18 ++++++++++++++++++
 g10/free-packet.c |    9 +++++++--
 g10/keyedit.c     |   10 +++-------
 g10/passphrase.c  |    9 +++------
 g10/pkclist.c     |    9 +++++----
 g10/pubkey-enc.c  |    6 ++----
 g10/revoke.c      |   10 ++++------
 g10/skclist.c     |    3 +--
 tests/ChangeLog   |    6 ++++++
 tests/asschk.c    |    5 ++++-
 10 files changed, 53 insertions(+), 32 deletions(-)


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




More information about the Gnupg-commits mailing list