aboutsummaryrefslogtreecommitdiffstats
path: root/g10/build-packet.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-06-09 15:40:53 +0000
committerWerner Koch <[email protected]>2023-07-05 09:15:55 +0000
commit8425cdcc8eb98a1e894f629f46ce32b5c52ea01a (patch)
tree7096ac5c66a62485e9d65506a8900e4a26814be2 /g10/build-packet.c
parentw32: Map ERROR_FILE_INVALID to EIO. (diff)
downloadgnupg-8425cdcc8eb98a1e894f629f46ce32b5c52ea01a.tar.gz
gnupg-8425cdcc8eb98a1e894f629f46ce32b5c52ea01a.zip
gpg: Print status line and proper diagnostics for write errors.
* common/iobuf.c (file_filter): Improve diagnostics. * g10/build-packet.c (do_plaintext): Make sure to cache all error cases. -- GnuPG-bug-id: 6528
Diffstat (limited to 'g10/build-packet.c')
-rw-r--r--g10/build-packet.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 63bfadbe0..5de5114fb 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -761,12 +761,20 @@ do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt )
if (nbytes == (size_t)(-1)
&& (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
+ * iobuf_copy does not reliable return (-1) in that case. */
+ rc = iobuf_error (out);
if(ctb_new_format_p (ctb) && !pt->len)
/* Turn off partial body length mode. */
iobuf_set_partial_body_length_mode (out, 0);
- if( pt->len && nbytes != pt->len )
- log_error("do_plaintext(): wrote %lu bytes but expected %lu bytes\n",
- (ulong)nbytes, (ulong)pt->len );
+ if (pt->len && nbytes != pt->len)
+ {
+ log_error ("do_plaintext(): wrote %lu bytes"
+ " but expected %lu bytes\n",
+ (ulong)nbytes, (ulong)pt->len );
+ if (!rc) /* Just in case no error was set */
+ rc = gpg_error (GPG_ERR_EIO);
+ }
}
return rc;