aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-05-16 10:37:45 +0000
committerWerner Koch <[email protected]>2025-05-16 12:26:45 +0000
commit8e529f92219453195073d8a37670dbdf1f3a7e30 (patch)
tree4769d2644ead6fbe92b05e8e41fa8aba9cde9f82
parentRevert "w32: On socket nonce mismatch close the socket." (diff)
downloadgnupg-8e529f92219453195073d8a37670dbdf1f3a7e30.tar.gz
gnupg-8e529f92219453195073d8a37670dbdf1f3a7e30.zip
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: Remove replacement code not any longer needed. (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
-rw-r--r--common/util.h7
-rw-r--r--g10/gpg.c1
-rw-r--r--g10/import.c7
-rw-r--r--g10/options.h2
4 files changed, 11 insertions, 6 deletions
diff --git a/common/util.h b/common/util.h
index acda2646e..4564009ce 100644
--- a/common/util.h
+++ b/common/util.h
@@ -39,12 +39,11 @@
* libgpg-error version. Define them here.
* Example: (#if GPG_ERROR_VERSION_NUMBER < 0x011500 // 1.21)
*/
-#if GPG_ERROR_VERSION_NUMBER < 0x012f00 /* 1.47 */
-# define GPG_ERR_BAD_PUK 320
-# define GPG_ERR_NO_RESET_CODE 321
-# define GPG_ERR_BAD_RESET_CODE 322
+#if GPGRT_VERSION_NUMBER < 0x013800 /* 1.56 */
+# define GPG_ERR_UNEXPECTED_PACKET 216
#endif
+
#ifndef EXTERN_UNLESS_MAIN_MODULE
# if !defined (INCLUDED_BY_MAIN_MODULE)
# define EXTERN_UNLESS_MAIN_MODULE extern
diff --git a/g10/gpg.c b/g10/gpg.c
index 5f9a4b042..296d5fceb 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -1058,6 +1058,7 @@ static struct compatibility_flags_s compatibility_flags [] =
{
{ COMPAT_PARALLELIZED, "parallelized" },
{ COMPAT_T7014_OLD, "t7014-old" },
+ { COMPAT_COMPR_KEYS, "compr-keys" },
{ 0, NULL }
};
diff --git a/g10/import.c b/g10/import.c
index 9fbebf39d..48f0d5459 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -1058,7 +1058,12 @@ read_block( IOBUF a, unsigned int options,
switch (pkt->pkttype)
{
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;
goto ready;
diff --git a/g10/options.h b/g10/options.h
index 59a3cab73..fe81a0baf 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -399,7 +399,7 @@ EXTERN_UNLESS_MAIN_MODULE int memory_stat_debug_mode;
/* Compatibility flags */
#define COMPAT_PARALLELIZED 1 /* Use threaded hashing for signatures. */
#define COMPAT_T7014_OLD 2 /* Use initial T7014 test data. */
-
+#define COMPAT_COMPR_KEYS 4 /* Allow import of compressed keys. (T7014) */
/* Compliance test macros. */
#define GNUPG (opt.compliance==CO_GNUPG || opt.compliance==CO_DE_VS)