1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

* parse-packet.c (parse): Only data-type packets are allowed to use

OpenPGP partial length encoding.
This commit is contained in:
David Shaw 2004-03-01 23:10:35 +00:00
parent 0a05d98b8b
commit 9eb128ef9b
2 changed files with 51 additions and 28 deletions

View File

@ -1,3 +1,8 @@
2004-03-01 David Shaw <dshaw@jabberwocky.com>
* parse-packet.c (parse): Only data-type packets are allowed to
use OpenPGP partial length encoding.
2004-02-25 David Shaw <dshaw@jabberwocky.com> 2004-02-25 David Shaw <dshaw@jabberwocky.com>
* delkey.c (do_delete_key): Allow deleting a public key with a * delkey.c (do_delete_key): Allow deleting a public key with a

View File

@ -332,34 +332,52 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
else { else {
hdr[hdrlen++] = c; hdr[hdrlen++] = c;
if( c < 192 ) if( c < 192 )
pktlen = c; pktlen = c;
else if( c < 224 ) { else if( c < 224 )
pktlen = (c - 192) * 256; {
if( (c = iobuf_get(inp)) == -1 ) { pktlen = (c - 192) * 256;
log_error("%s: 2nd length byte missing\n", if( (c = iobuf_get(inp)) == -1 )
iobuf_where(inp) ); {
rc = G10ERR_INVALID_PACKET; log_error("%s: 2nd length byte missing\n",
goto leave; iobuf_where(inp) );
} rc = G10ERR_INVALID_PACKET;
hdr[hdrlen++] = c; goto leave;
pktlen += c + 192; }
} hdr[hdrlen++] = c;
else if( c == 255 ) { pktlen += c + 192;
pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24; }
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16; else if( c == 255 )
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8; {
if( (c = iobuf_get(inp)) == -1 ) { pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
log_error("%s: 4 byte length invalid\n", pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16;
iobuf_where(inp) ); pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8;
rc = G10ERR_INVALID_PACKET; if( (c = iobuf_get(inp)) == -1 )
goto leave; {
} log_error("%s: 4 byte length invalid\n",
pktlen |= (hdr[hdrlen++] = c ); iobuf_where(inp) );
} rc = G10ERR_INVALID_PACKET;
else { /* partial body length */ goto leave;
iobuf_set_partial_block_mode(inp, c & 0xff); }
pktlen = 0;/* to indicate partial length */ pktlen |= (hdr[hdrlen++] = c );
} }
else
{
/* Partial body length. Note that we handled
PKT_COMPRESSED earlier. */
if(pkttype==PKT_PLAINTEXT || pkttype==PKT_ENCRYPTED
|| pkttype==PKT_ENCRYPTED_MDC)
{
iobuf_set_partial_block_mode(inp, c & 0xff);
pktlen = 0;/* to indicate partial length */
}
else
{
log_error("%s: partial length for invalid"
" packet type %d\n",iobuf_where(inp),pkttype);
rc=G10ERR_INVALID_PACKET;
goto leave;
}
}
} }
} }
else { else {