1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-05-24 16:43:28 +02:00

gpg: Do not allow compressed key packets on import.

* g10/import.c (read_block): Bail out on compressed packets.
* g10/options.h (COMPAT_COMPR_KEYS): New.
* g10/gpg.c (compatibility_flags): Add "compr-keys".
* common/util.h (GPG_ERR_UNEXPECTED_PACKET): Add a new replacement
code.
--

Compressed key packets do not make much sense but historically they
were supported.  Thus we also add a compatibility flag.

GnuPG-bug-id: 7014
Backported-from-master: 8e529f92219453195073d8a37670dbdf1f3a7e30
This commit is contained in:
Werner Koch 2025-05-16 12:37:45 +02:00
parent d48b26a2f6
commit 23ccad05c6
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 11 additions and 2 deletions

View File

@ -44,6 +44,9 @@
# define GPG_ERR_NO_RESET_CODE 321 # define GPG_ERR_NO_RESET_CODE 321
# define GPG_ERR_BAD_RESET_CODE 322 # define GPG_ERR_BAD_RESET_CODE 322
#endif #endif
#if GPGRT_VERSION_NUMBER < 0x013800 /* 1.56 */
# define GPG_ERR_UNEXPECTED_PACKET 216
#endif
#ifndef EXTERN_UNLESS_MAIN_MODULE #ifndef EXTERN_UNLESS_MAIN_MODULE
# if !defined (INCLUDED_BY_MAIN_MODULE) # if !defined (INCLUDED_BY_MAIN_MODULE)

View File

@ -1037,6 +1037,7 @@ static struct debug_flags_s debug_flags [] =
/* The list of compatibility flags. */ /* The list of compatibility flags. */
static struct compatibility_flags_s compatibility_flags [] = static struct compatibility_flags_s compatibility_flags [] =
{ {
{ COMPAT_COMPR_KEYS, "compr-keys" },
{ 0, NULL } { 0, NULL }
}; };

View File

@ -1057,7 +1057,12 @@ read_block( IOBUF a, unsigned int options,
switch (pkt->pkttype) switch (pkt->pkttype)
{ {
case PKT_COMPRESSED: case PKT_COMPRESSED:
if (check_compress_algo (pkt->pkt.compressed->algorithm)) if (!(opt.compat_flags & COMPAT_COMPR_KEYS))
{
rc = GPG_ERR_UNEXPECTED_PACKET;
goto ready;
}
else if (check_compress_algo (pkt->pkt.compressed->algorithm))
{ {
rc = GPG_ERR_COMPR_ALGO; rc = GPG_ERR_COMPR_ALGO;
goto ready; goto ready;

View File

@ -387,7 +387,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_debug_mode;
EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode; EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
/* Compatibility flags */ /* Compatibility flags */
/* #define COMPAT_FOO 1 */ #define COMPAT_COMPR_KEYS 4 /* Allow import of compressed keys. (T7014) */
/* Compliance test macors. */ /* Compliance test macors. */