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:
parent
0a05d98b8b
commit
9eb128ef9b
@ -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>
|
||||
|
||||
* delkey.c (do_delete_key): Allow deleting a public key with a
|
||||
|
@ -332,34 +332,52 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
|
||||
else {
|
||||
hdr[hdrlen++] = c;
|
||||
if( c < 192 )
|
||||
pktlen = c;
|
||||
else if( c < 224 ) {
|
||||
pktlen = (c - 192) * 256;
|
||||
if( (c = iobuf_get(inp)) == -1 ) {
|
||||
log_error("%s: 2nd length byte missing\n",
|
||||
iobuf_where(inp) );
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
goto leave;
|
||||
}
|
||||
hdr[hdrlen++] = c;
|
||||
pktlen += c + 192;
|
||||
}
|
||||
else if( c == 255 ) {
|
||||
pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
|
||||
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16;
|
||||
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8;
|
||||
if( (c = iobuf_get(inp)) == -1 ) {
|
||||
log_error("%s: 4 byte length invalid\n",
|
||||
iobuf_where(inp) );
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
goto leave;
|
||||
}
|
||||
pktlen |= (hdr[hdrlen++] = c );
|
||||
}
|
||||
else { /* partial body length */
|
||||
iobuf_set_partial_block_mode(inp, c & 0xff);
|
||||
pktlen = 0;/* to indicate partial length */
|
||||
}
|
||||
pktlen = c;
|
||||
else if( c < 224 )
|
||||
{
|
||||
pktlen = (c - 192) * 256;
|
||||
if( (c = iobuf_get(inp)) == -1 )
|
||||
{
|
||||
log_error("%s: 2nd length byte missing\n",
|
||||
iobuf_where(inp) );
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
goto leave;
|
||||
}
|
||||
hdr[hdrlen++] = c;
|
||||
pktlen += c + 192;
|
||||
}
|
||||
else if( c == 255 )
|
||||
{
|
||||
pktlen = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
|
||||
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16;
|
||||
pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8;
|
||||
if( (c = iobuf_get(inp)) == -1 )
|
||||
{
|
||||
log_error("%s: 4 byte length invalid\n",
|
||||
iobuf_where(inp) );
|
||||
rc = G10ERR_INVALID_PACKET;
|
||||
goto leave;
|
||||
}
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user