mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg: Fix a NULL-deref in export due to invalid packet lengths.
* g10/build-packet.c (write_fake_data): Take care of a NULL stored as opaque MPI. -- Reported-by: Hanno Böck <hanno@hboeck.de> Test data: gpg2 --no-default-keyring --keyring FILE --export With this unpacked data for FILE: -----BEGIN PGP ARMORED FILE----- Version: GnuPG v2 Comment: Use "gpg --dearmor" for unpacking mI0EGRkZGRkZGRkZGRkZGRkBGRkZGRkZGRkZGRkZGQAZGRkZGRkZGRkZGRkZGRkZ GRkZInzgDbpa/9gQ4wq9////f3Vy81CkyVq3HQaqgZLZOeqPjM7XgGh5hJvAkpec 9wAAAgDHe0FVFbkppJZXP+gFs6z3gobS0qUFeyTtxs+wAgAD =JDFT -----END PGP ARMORED FILE----- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
3997848786
commit
0835d2f44e
@ -261,6 +261,9 @@ write_fake_data (IOBUF out, gcry_mpi_t a)
|
||||
if (!a)
|
||||
return 0;
|
||||
p = gcry_mpi_get_opaque ( a, &n);
|
||||
if (!p)
|
||||
return 0; /* For example due to a read error in
|
||||
parse-packet.c:read_rest. */
|
||||
return iobuf_write (out, p, (n+7)/8 );
|
||||
}
|
||||
|
||||
@ -305,9 +308,9 @@ do_key (iobuf_t out, int ctb, PKT_public_key *pk)
|
||||
nskey = pubkey_get_nskey (pk->pubkey_algo);
|
||||
npkey = pubkey_get_npkey (pk->pubkey_algo);
|
||||
|
||||
/* If we don't have any public parameters - which is the case if we
|
||||
don't know the algorithm used - the parameters are stored as one
|
||||
blob in a faked (opaque) MPI. */
|
||||
/* If we don't have any public parameters - which is for example the
|
||||
case if we don't know the algorithm used - the parameters are
|
||||
stored as one blob in a faked (opaque) MPI. */
|
||||
if (!npkey)
|
||||
{
|
||||
write_fake_data (a, pk->pkey[0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user