aboutsummaryrefslogtreecommitdiffstats
path: root/g10/parse-packet.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2003-06-10 09:05:38 +0000
committerWerner Koch <[email protected]>2003-06-10 09:05:38 +0000
commit66a7843c94a86352c0136036b9e0b5ad91def2a9 (patch)
treec1819cb939daa586daf73c0f03a43fff83842a30 /g10/parse-packet.c
parent* import.c (import_keys_internal): Invalidate the cache so that (diff)
downloadgnupg-66a7843c94a86352c0136036b9e0b5ad91def2a9.tar.gz
gnupg-66a7843c94a86352c0136036b9e0b5ad91def2a9.zip
* parse-packet.c (parse): Disallow old style partial length for
all key material packets to avoid possible corruption of keyrings.
Diffstat (limited to 'g10/parse-packet.c')
-rw-r--r--g10/parse-packet.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index dddff86a2..bdf68c551 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-- ) {