mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
* free-packet.c (copy_secret_key): Fixed memory leak when D is not
NULL. * passphrase.c (passphrase_to_dek): Added a few comments to the code.
This commit is contained in:
parent
7e165d9758
commit
5c9cc2e867
@ -1,3 +1,11 @@
|
|||||||
|
2004-06-16 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* free-packet.c (copy_secret_key): Fixed memory leak when D is not
|
||||||
|
NULL.
|
||||||
|
|
||||||
|
* passphrase.c (passphrase_to_dek): Added a few comments to the
|
||||||
|
code.
|
||||||
|
|
||||||
2004-05-26 David Shaw <dshaw@jabberwocky.com>
|
2004-05-26 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* keyserver.c (keyserver_refresh): Keep track of keys already
|
* keyserver.c (keyserver_refresh): Keep track of keys already
|
||||||
|
@ -265,11 +265,19 @@ copy_secret_key( PKT_secret_key *d, PKT_secret_key *s )
|
|||||||
memcpy( d, s, sizeof *d );
|
memcpy( d, s, sizeof *d );
|
||||||
n = pubkey_get_nskey( s->pubkey_algo );
|
n = pubkey_get_nskey( s->pubkey_algo );
|
||||||
if( !n )
|
if( !n )
|
||||||
|
{
|
||||||
|
if (d->skey[0])
|
||||||
|
mpi_free (d->skey[0]);
|
||||||
d->skey[0] = mpi_copy(s->skey[0]);
|
d->skey[0] = mpi_copy(s->skey[0]);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for(i=0; i < n; i++ )
|
for(i=0; i < n; i++ )
|
||||||
|
{
|
||||||
|
if (d->skey[1])
|
||||||
|
mpi_free (d->skey[1]);
|
||||||
d->skey[i] = mpi_copy( s->skey[i] );
|
d->skey[i] = mpi_copy( s->skey[i] );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,7 +1057,13 @@ ask_passphrase (const char *description,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Return a new DEK object Using the string-to-key sepcifier S2K. Use
|
||||||
|
* KEYID and PUBKEY_ALGO to prompt the user.
|
||||||
|
|
||||||
|
MODE 0: Allow cached passphrase
|
||||||
|
1: Ignore cached passphrase
|
||||||
|
2: Ditto, but change the text to "repeat entry"
|
||||||
|
*/
|
||||||
DEK *
|
DEK *
|
||||||
passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
||||||
int cipher_algo, STRING2KEY *s2k, int mode,
|
int cipher_algo, STRING2KEY *s2k, int mode,
|
||||||
@ -1078,6 +1084,8 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
s2k->hash_algo = opt.s2k_digest_algo;
|
s2k->hash_algo = opt.s2k_digest_algo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we do not have a passphrase available in NEXT_PW and status
|
||||||
|
information are request, we print them now. */
|
||||||
if( !next_pw && is_status_enabled() ) {
|
if( !next_pw && is_status_enabled() ) {
|
||||||
char buf[50];
|
char buf[50];
|
||||||
|
|
||||||
@ -1111,6 +1119,10 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we do have a keyID, we do not have a passphrase available in
|
||||||
|
NEXT_PW, we are not running in batch mode and we do not want to
|
||||||
|
ignore the passphrase cache (mode!=1), print a prompt with
|
||||||
|
information on that key. */
|
||||||
if( keyid && !opt.batch && !next_pw && mode!=1 ) {
|
if( keyid && !opt.batch && !next_pw && mode!=1 ) {
|
||||||
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
PKT_public_key *pk = m_alloc_clear( sizeof *pk );
|
||||||
size_t n;
|
size_t n;
|
||||||
@ -1149,10 +1161,12 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
|
|
||||||
agent_died:
|
agent_died:
|
||||||
if( next_pw ) {
|
if( next_pw ) {
|
||||||
|
/* Simply return the passpharse we already have in NEXT_PW. */
|
||||||
pw = next_pw;
|
pw = next_pw;
|
||||||
next_pw = NULL;
|
next_pw = NULL;
|
||||||
}
|
}
|
||||||
else if ( opt.use_agent ) {
|
else if ( opt.use_agent ) {
|
||||||
|
/* Divert to teh gpg-agent. */
|
||||||
pw = agent_get_passphrase ( keyid, mode == 2? 1: 0,
|
pw = agent_get_passphrase ( keyid, mode == 2? 1: 0,
|
||||||
tryagain_text, canceled );
|
tryagain_text, canceled );
|
||||||
if (!pw)
|
if (!pw)
|
||||||
@ -1182,6 +1196,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( fd_passwd ) {
|
else if( fd_passwd ) {
|
||||||
|
/* Return the passphrase we have store in FD_PASSWD. */
|
||||||
pw = m_alloc_secure( strlen(fd_passwd)+1 );
|
pw = m_alloc_secure( strlen(fd_passwd)+1 );
|
||||||
strcpy( pw, fd_passwd );
|
strcpy( pw, fd_passwd );
|
||||||
}
|
}
|
||||||
@ -1190,6 +1205,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
pw = m_strdup( "" ); /* return an empty passphrase */
|
pw = m_strdup( "" ); /* return an empty passphrase */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
/* Read the passphrase from the tty or the command-fd. */
|
||||||
pw = cpr_get_hidden("passphrase.enter", _("Enter passphrase: ") );
|
pw = cpr_get_hidden("passphrase.enter", _("Enter passphrase: ") );
|
||||||
tty_kill_prompt();
|
tty_kill_prompt();
|
||||||
if( mode == 2 && !cpr_enabled() ) {
|
if( mode == 2 && !cpr_enabled() ) {
|
||||||
@ -1208,6 +1224,9 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
|
|||||||
if( !pw || !*pw )
|
if( !pw || !*pw )
|
||||||
write_status( STATUS_MISSING_PASSPHRASE );
|
write_status( STATUS_MISSING_PASSPHRASE );
|
||||||
|
|
||||||
|
/* Hash the passphrase and store it in a newly allocated DEK
|
||||||
|
object. Keep a copy of the passphrase in LAST_PW for use by
|
||||||
|
get_last_passphrase(). */
|
||||||
dek = m_alloc_secure_clear ( sizeof *dek );
|
dek = m_alloc_secure_clear ( sizeof *dek );
|
||||||
dek->algo = cipher_algo;
|
dek->algo = cipher_algo;
|
||||||
if( !*pw && mode == 2 )
|
if( !*pw && mode == 2 )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user