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

@ -333,9 +333,11 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
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; pktlen = (c - 192) * 256;
if( (c = iobuf_get(inp)) == -1 ) { if( (c = iobuf_get(inp)) == -1 )
{
log_error("%s: 2nd length byte missing\n", log_error("%s: 2nd length byte missing\n",
iobuf_where(inp) ); iobuf_where(inp) );
rc = G10ERR_INVALID_PACKET; rc = G10ERR_INVALID_PACKET;
@ -344,11 +346,13 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
hdr[hdrlen++] = c; hdr[hdrlen++] = c;
pktlen += c + 192; pktlen += c + 192;
} }
else if( c == 255 ) { else if( c == 255 )
{
pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24; pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16; pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16;
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8; pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8;
if( (c = iobuf_get(inp)) == -1 ) { if( (c = iobuf_get(inp)) == -1 )
{
log_error("%s: 4 byte length invalid\n", log_error("%s: 4 byte length invalid\n",
iobuf_where(inp) ); iobuf_where(inp) );
rc = G10ERR_INVALID_PACKET; rc = G10ERR_INVALID_PACKET;
@ -356,10 +360,24 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
} }
pktlen |= (hdr[hdrlen++] = c ); pktlen |= (hdr[hdrlen++] = c );
} }
else { /* partial body length */ 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); iobuf_set_partial_block_mode(inp, c & 0xff);
pktlen = 0;/* to indicate partial length */ 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 {