Fix a signal cleanup problem.

Fix zero length MPI reading.
This commit is contained in:
Werner Koch 2009-05-26 09:29:02 +00:00
parent e095815c4d
commit 21ad035cc9
3 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2009-05-26 Werner Koch <wk@g10code.com>
* parse-packet.c (mpi_read): Workaround for zero-length MPI bug in
libgcrypt<1.5.0.
2009-05-22 Werner Koch <wk@g10code.com>
* signal.c (got_fatal_signal): Call new function
tty_cleanup_after_signal.
2009-05-20 Werner Koch <wk@g10code.com>
* gpg.c (main): Fix --fingerprint/--with-fingerprint command

View File

@ -139,9 +139,19 @@ mpi_read (iobuf_t inp, unsigned int *ret_nread, int secure)
p[i+2] = iobuf_get(inp) & 0xff;
nread++;
}
if ( gcry_mpi_scan( &a, GCRYMPI_FMT_PGP, buf, nread, &nread ) )
a = NULL;
if (nread >= 2 && !(buf[0] << 8 | buf[1]))
{
/* Libgcrypt < 1.5.0 accidently rejects zero-length (i.e. zero)
MPIs. We fix this here. */
a = gcry_mpi_new (0);
}
else
{
if ( gcry_mpi_scan( &a, GCRYMPI_FMT_PGP, buf, nread, &nread ) )
a = NULL;
}
leave:
gcry_free(buf);
if ( nread > *ret_nread )

View File

@ -81,6 +81,7 @@ got_fatal_signal( int sig )
gcry_control (GCRYCTL_TERM_SECMEM );
tty_cleanup_rl_after_signal ();
tty_cleanup_after_signal ();
/* Better don't translate these messages. */
write(2, "\n", 1 );