aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2003-06-10 08:34:53 +0000
committerWerner Koch <[email protected]>2003-06-10 08:34:53 +0000
commit0848d55ff37f0c0e1b9a6d2cd12bbc00d66936bc (patch)
treeef9f0d1f8398df7ebe1b98c5132785dad267c71c
parent* import.c (import_keys): Invalidate the cache so that the file (diff)
downloadgnupg-0848d55ff37f0c0e1b9a6d2cd12bbc00d66936bc.tar.gz
gnupg-0848d55ff37f0c0e1b9a6d2cd12bbc00d66936bc.zip
* parse-packet.c (parse): Disallow old style partial length for
all key material packets to avoid possible corruption of keyrings.
-rw-r--r--g10/ChangeLog5
-rw-r--r--g10/parse-packet.c24
2 files changed, 27 insertions, 2 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 702ee4216..16098ee49 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,8 @@
+2003-06-10 Werner Koch <[email protected]>
+
+ * parse-packet.c (parse): Disallow old style partial length for
+ all key material packets to avoid possible corruption of keyrings.
+
2003-06-08 Werner Koch <[email protected]>
* import.c (import_keys): Invalidate the cache so that the file
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 8a3235fe3..8e165ef25 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -367,8 +367,28 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
if( !lenbytes ) {
pktlen = 0; /* don't know the value */
- if( pkttype != PKT_COMPRESSED )
- iobuf_set_block_mode(inp, 1);
+ switch (pkttype) {
+ case PKT_ENCRYPTED:
+ case PKT_PLAINTEXT:
+ /* These partial length encodings are from an very
+ early GnuPG release and deprecated. However we
+ still support them read-wise. Note, that we should
+ not allow them for any key related packets, because
+ this might render a keyring unusable if an errenous
+ packet indicated this mode but not complying to it
+ gets imported. */
+ iobuf_set_block_mode(inp, 1);
+ break;
+
+ case PKT_COMPRESSED:
+ break; /* the orginal pgp 2 way. */
+
+ default:
+ log_error ("%s: old style partial length "
+ "for invalid packet type\n", iobuf_where(inp) );
+ rc = G10ERR_INVALID_PACKET;
+ goto leave;
+ }
}
else {
for( ; lenbytes; lenbytes-- ) {