1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-20 14:51:42 +02:00

gpg: Improve detection of input data read errors.

* g10/build-packet.c (do_plaintext): Better error checking for
iobuf_copy.
--

Fixes-commit: 695cb04af5
GnuPG-bug-id: 6528

The original fix handles only the disk full case but didn't bother
about read errors (i.e. I/O problems on an external drive).
This commit is contained in:
Werner Koch 2024-09-06 16:08:53 +02:00
parent 9a741aba3d
commit 2cc340eca0
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -1064,9 +1064,16 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
if (nbytes == (size_t)(-1) if (nbytes == (size_t)(-1)
&& (iobuf_error (out) || iobuf_error (pt->buf))) && (iobuf_error (out) || iobuf_error (pt->buf)))
return iobuf_error (out)? iobuf_error (out):iobuf_error (pt->buf); return iobuf_error (out)? iobuf_error (out):iobuf_error (pt->buf);
/* Always get the error to catch write errors because else if (nbytes != (size_t)(-1) && iobuf_error (pt->buf))
* iobuf_copy does not reliable return (-1) in that case. */ rc = iobuf_error (pt->buf); /* Read error. */
rc = iobuf_error (out); else
{
/* Always get the iobuf error to catch write errors
* because iobuf_copy returns (-1) only if there was a
* errors in the output stream when entering that
* function. */
rc = iobuf_error (out);
}
if(ctb_new_format_p (ctb) && !pt->len) if(ctb_new_format_p (ctb) && !pt->len)
/* Turn off partial body length mode. */ /* Turn off partial body length mode. */
iobuf_set_partial_body_length_mode (out, 0); iobuf_set_partial_body_length_mode (out, 0);