mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-07 17:33:02 +01:00
gpg: Fix a practical hang after use of --faked-system-time.
* g10/sign.c (update_keysig_packet): Bail out if we would need to long for a new timestamp. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
2c60663a72
commit
2acceba5cc
@ -663,7 +663,7 @@ int make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk,
|
|||||||
int (*mksubpkt)(PKT_signature *, void *),
|
int (*mksubpkt)(PKT_signature *, void *),
|
||||||
void *opaque,
|
void *opaque,
|
||||||
const char *cache_nonce);
|
const char *cache_nonce);
|
||||||
int update_keysig_packet( PKT_signature **ret_sig,
|
gpg_error_t update_keysig_packet (PKT_signature **ret_sig,
|
||||||
PKT_signature *orig_sig,
|
PKT_signature *orig_sig,
|
||||||
PKT_public_key *pk,
|
PKT_public_key *pk,
|
||||||
PKT_user_id *uid,
|
PKT_user_id *uid,
|
||||||
|
23
g10/sign.c
23
g10/sign.c
@ -1477,7 +1477,7 @@ make_keysig_packet (PKT_signature **ret_sig, PKT_public_key *pk,
|
|||||||
*
|
*
|
||||||
* TODO: Merge this with make_keysig_packet.
|
* TODO: Merge this with make_keysig_packet.
|
||||||
*/
|
*/
|
||||||
int
|
gpg_error_t
|
||||||
update_keysig_packet( PKT_signature **ret_sig,
|
update_keysig_packet( PKT_signature **ret_sig,
|
||||||
PKT_signature *orig_sig,
|
PKT_signature *orig_sig,
|
||||||
PKT_public_key *pk,
|
PKT_public_key *pk,
|
||||||
@ -1488,7 +1488,7 @@ update_keysig_packet( PKT_signature **ret_sig,
|
|||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
PKT_signature *sig;
|
PKT_signature *sig;
|
||||||
int rc = 0;
|
gpg_error_t rc = 0;
|
||||||
int digest_algo;
|
int digest_algo;
|
||||||
gcry_md_hd_t md;
|
gcry_md_hd_t md;
|
||||||
|
|
||||||
@ -1524,11 +1524,19 @@ update_keysig_packet( PKT_signature **ret_sig,
|
|||||||
|
|
||||||
/* ... but we won't make a timestamp earlier than the existing
|
/* ... but we won't make a timestamp earlier than the existing
|
||||||
one. */
|
one. */
|
||||||
while(sig->timestamp<=orig_sig->timestamp)
|
{
|
||||||
{
|
int tmout = 0;
|
||||||
gnupg_sleep (1);
|
while(sig->timestamp<=orig_sig->timestamp)
|
||||||
sig->timestamp=make_timestamp();
|
{
|
||||||
}
|
if (++tmout > 5 && !opt.ignore_time_conflict)
|
||||||
|
{
|
||||||
|
rc = gpg_error (GPG_ERR_TIME_CONFLICT);
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
gnupg_sleep (1);
|
||||||
|
sig->timestamp=make_timestamp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Note that already expired sigs will remain expired (with a
|
/* Note that already expired sigs will remain expired (with a
|
||||||
duration of 1) since build-packet.c:build_sig_subpkt_from_sig
|
duration of 1) since build-packet.c:build_sig_subpkt_from_sig
|
||||||
@ -1550,6 +1558,7 @@ update_keysig_packet( PKT_signature **ret_sig,
|
|||||||
rc = complete_sig (sig, pksk, md, NULL);
|
rc = complete_sig (sig, pksk, md, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave:
|
||||||
gcry_md_close (md);
|
gcry_md_close (md);
|
||||||
if( rc )
|
if( rc )
|
||||||
free_seckey_enc (sig);
|
free_seckey_enc (sig);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user