aboutsummaryrefslogtreecommitdiffstats
path: root/g10/parse-packet.c
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2004-03-03 16:38:34 +0000
committerDavid Shaw <[email protected]>2004-03-03 16:38:34 +0000
commit56a6945261b543a3995017ed610191a3d32faf9c (patch)
tree3739a0e3e55f13a4fbef7efcd99a34eaaf4c1277 /g10/parse-packet.c
parent* options.h, g10.c (main): Add a more flexible --keyid-format option to (diff)
downloadgnupg-56a6945261b543a3995017ed610191a3d32faf9c.tar.gz
gnupg-56a6945261b543a3995017ed610191a3d32faf9c.zip
* build-packet.c (write_header2): Remove call to start old gpg partial
length mode and change all callers. (do_plaintext): Turn off partial length encoding now that we're done writing the packet. (do_comment, do_user_id): Try for a headerlen of 2 since that's the smallest and most likely encoding for these packets. * parse-packet.c (parse): Remove call to start old gpg partial length mode.
Diffstat (limited to '')
-rw-r--r--g10/parse-packet.c52
1 files changed, 22 insertions, 30 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 1029a96b5..0a2892ac0 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -383,42 +383,34 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
}
}
}
- else {
+ else
+ {
pkttype = (ctb>>2)&0xf;
lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
- if( !lenbytes ) {
+ if( !lenbytes )
+ {
pktlen = 0; /* don't know the value */
+ /* This isn't really partial, but we can treat it the same
+ in a "read until the end" sort of way. */
partial=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 %d\n", iobuf_where(inp), pkttype );
- rc = G10ERR_INVALID_PACKET;
- goto leave;
- }
- }
- else {
- for( ; lenbytes; lenbytes-- ) {
+ if(pkttype!=PKT_ENCRYPTED && pkttype!=PKT_PLAINTEXT
+ && pkttype!=PKT_COMPRESSED)
+ {
+ log_error ("%s: indeterminate length for invalid"
+ " packet type %d\n", iobuf_where(inp), pkttype );
+ rc = G10ERR_INVALID_PACKET;
+ goto leave;
+ }
+ }
+ else
+ {
+ for( ; lenbytes; lenbytes-- )
+ {
pktlen <<= 8;
pktlen |= hdr[hdrlen++] = iobuf_get_noeof(inp);
- }
- }
- }
+ }
+ }
+ }
if (pktlen == 0xffffffff) {
/* with a some probability this is caused by a problem in the