aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2007-07-18 17:08:47 +0000
committerDavid Shaw <[email protected]>2007-07-18 17:08:47 +0000
commitd26739aa5a31c2a7d0ba4862cbab840365ec4802 (patch)
tree04ea11a1ddb5e367a24838b67ea2dd5f74276b11
parentAdd an extra warning for Camellia. (diff)
downloadgnupg-d26739aa5a31c2a7d0ba4862cbab840365ec4802.tar.gz
gnupg-d26739aa5a31c2a7d0ba4862cbab840365ec4802.zip
* armor.c (is_armor_tag): New. Detect if an armor header matches
2440bis-21. (parse_header_line): Call it here, as bis-21 requires warning the user (but continuing to process the message) when seeing an unknown header.
-rw-r--r--g10/ChangeLog8
-rw-r--r--g10/armor.c28
2 files changed, 34 insertions, 2 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 9c941d15a..b6f73f667 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,11 @@
+2007-07-18 David Shaw <[email protected]>
+
+ * armor.c (is_armor_tag): New. Detect if an armor header matches
+ 2440bis-21.
+ (parse_header_line): Call it here, as bis-21 requires warning the
+ user (but continuing to process the message) when seeing an
+ unknown header.
+
2007-07-09 Werner Koch <[email protected]>
* gpg.c: Better print an extra warning if Camellia has been
diff --git a/g10/armor.c b/g10/armor.c
index 65804a75b..5a6319e65 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -1,6 +1,6 @@
/* armor.c - Armor flter
- * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- * 2006 Free Software Foundation, Inc.
+ * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ * 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -314,7 +314,19 @@ parse_hash_header( const char *line )
return found;
}
+/* Returns true if this is a valid armor tag as per RFC-2440bis-21. */
+static int
+is_armor_tag(const char *line)
+{
+ if(strncmp(line,"Version",7)==0
+ || strncmp(line,"Comment",7)==0
+ || strncmp(line,"MessageID",9)==0
+ || strncmp(line,"Hash",4)==0
+ || strncmp(line,"Charset",7)==0)
+ return 1;
+ return 0;
+}
/****************
* Check whether this is a armor line.
@@ -424,6 +436,18 @@ parse_header_line( armor_filter_context_t *afx, byte *line, unsigned int len )
putc('\n', stderr);
}
+ /* Section 6.2: OpenPGP should consider improperly formatted Armor
+ Headers to be corruption of the ASCII Armor. Unknown keys
+ should be reported to the user, but OpenPGP should continue to
+ process the message. */
+
+ if(!is_armor_tag(line))
+ {
+ log_info(_("unknown armor header: "));
+ print_string( stderr, line, len, 0 );
+ putc('\n', stderr);
+ }
+
if( afx->in_cleartext ) {
if( (hashes=parse_hash_header( line )) )
afx->hashes |= hashes;