mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-30 16:17:02 +01:00
Allow NULL for free_public_key.
This commit is contained in:
parent
850f09b2e3
commit
6cf8890dc1
@ -1,3 +1,14 @@
|
||||
2011-09-20 Werner Koch <wk@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@redhat.com>
|
||||
|
||||
avoid use of freed pointer
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 )
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
13
g10/revoke.c
13
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 );
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user