mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg: Fix assertion failure due to errors in encrypt_filter.
* common/iobuf.c (iobuf_copy): Use log_assert. Explicitly cast error return value. * g10/build-packet.c (do_plaintext): Check for iobuf_copy error. * g10/encrypt.c (encrypt_filter): Immediately set header_okay. -- The second fix avoids repeated error message about non-compliant keys. Updates-commit: a51067a21f688086bd8e44234a88ae367582cc76 Ported-from: aa0c942521d89f4f0aac90bacaf8a7a7cefc88d8 GnuPG-bug-id: 6174
This commit is contained in:
parent
a51067a21f
commit
46f9b0071f
@ -2430,7 +2430,7 @@ iobuf_temp_to_buffer (iobuf_t a, byte * buffer, size_t buflen)
|
||||
|
||||
/* Copies the data from the input iobuf SOURCE to the output iobuf
|
||||
DEST until either an error is encountered or EOF is reached.
|
||||
Returns the number of bytes copies. */
|
||||
Returns the number of bytes copies or (size_t)(-1) on error. */
|
||||
size_t
|
||||
iobuf_copy (iobuf_t dest, iobuf_t source)
|
||||
{
|
||||
@ -2441,11 +2441,11 @@ iobuf_copy (iobuf_t dest, iobuf_t source)
|
||||
size_t max_read = 0;
|
||||
int err;
|
||||
|
||||
assert (source->use == IOBUF_INPUT || source->use == IOBUF_INPUT_TEMP);
|
||||
assert (dest->use == IOBUF_OUTPUT || source->use == IOBUF_OUTPUT_TEMP);
|
||||
log_assert (source->use == IOBUF_INPUT || source->use == IOBUF_INPUT_TEMP);
|
||||
log_assert (dest->use == IOBUF_OUTPUT || source->use == IOBUF_OUTPUT_TEMP);
|
||||
|
||||
if (iobuf_error (dest))
|
||||
return -1;
|
||||
return (size_t)(-1);
|
||||
|
||||
/* Use iobuf buffer size for temporary buffer. */
|
||||
temp_size = iobuf_set_buffer_size(0) * 1024;
|
||||
|
@ -970,6 +970,9 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
|
||||
if (pt->buf)
|
||||
{
|
||||
nbytes = iobuf_copy (out, pt->buf);
|
||||
if (nbytes == (size_t)(-1)
|
||||
&& (iobuf_error (out) || iobuf_error (pt->buf)))
|
||||
return iobuf_error (out)? iobuf_error (out):iobuf_error (pt->buf);
|
||||
if(ctb_new_format_p (ctb) && !pt->len)
|
||||
/* Turn off partial body length mode. */
|
||||
iobuf_set_partial_body_length_mode (out, 0);
|
||||
|
@ -1060,6 +1060,8 @@ encrypt_filter (void *opaque, int control,
|
||||
{
|
||||
if ( !efx->header_okay )
|
||||
{
|
||||
efx->header_okay = 1;
|
||||
|
||||
efx->cfx.dek = create_dek_with_warnings (efx->pk_list);
|
||||
|
||||
rc = check_encryption_compliance (efx->cfx.dek, efx->pk_list);
|
||||
@ -1092,7 +1094,6 @@ encrypt_filter (void *opaque, int control,
|
||||
/**/ : cipher_filter_cfb,
|
||||
&efx->cfx);
|
||||
|
||||
efx->header_okay = 1;
|
||||
}
|
||||
rc = iobuf_write (a, buf, size);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user