mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: Limit the nesting level of I/O filters.
* common/iobuf.c (MAX_NESTING_FILTER): New. (iobuf_push_filter2): Limit the nesting level. * g10/mainproc.c (mainproc_context): New field ANY. Change HAVE_DATA and ANY_SIG_SIGN to bit fields of ANY. Add bit field UNCOMPRESS_FAILED. (proc_compressed): Avoid printing multiple Bad Data messages. (check_nesting): Return GPG_ERR_BAD_DATA instead of UNEXPECTED_DATA. -- This is a more general fix for the nested compression packet bug. In particular this helps g10/import.c:read_block to stop pushing compression filters onto an iobuf stream. This patch also reduces the number of error messages for the non-import case. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
cd1b696b28
commit
35e40e2d51
2 changed files with 59 additions and 30 deletions
|
@ -55,6 +55,10 @@
|
|||
be aware that there is no fsync support for the stdio backend. */
|
||||
#undef FILE_FILTER_USES_STDIO
|
||||
|
||||
/* To avoid a potential DoS with compression packets we better limit
|
||||
the number of filters in a chain. */
|
||||
#define MAX_NESTING_FILTER 64
|
||||
|
||||
/*-- End configurable part. --*/
|
||||
|
||||
|
||||
|
@ -1615,6 +1619,13 @@ iobuf_push_filter2 (iobuf_t a,
|
|||
|
||||
if (a->use == 2 && (rc = iobuf_flush (a)))
|
||||
return rc;
|
||||
|
||||
if (a->subno >= MAX_NESTING_FILTER)
|
||||
{
|
||||
log_error ("i/o filter too deeply nested - corrupted data?\n");
|
||||
return GPG_ERR_BAD_DATA;
|
||||
}
|
||||
|
||||
/* make a copy of the current stream, so that
|
||||
* A is the new stream and B the original one.
|
||||
* The contents of the buffers are transferred to the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue