summaryrefslogtreecommitdiffstats
path: root/g10/decrypt.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2023-07-05 03:21:23 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2023-07-05 03:29:23 +0200
commit3fb69641e84d420ee331023a53ac2961d17fa8b6 (patch)
tree6220ce7d4a34e067d247adb95667c6949f1cd172 /g10/decrypt.c
parentgpg: Use gnupg_fd_t for encrypt_crypt and gpg_verify. (diff)
downloadgnupg2-3fb69641e84d420ee331023a53ac2961d17fa8b6.tar.xz
gnupg2-3fb69641e84d420ee331023a53ac2961d17fa8b6.zip
gpg: Use gnupg_fd_t for decryption and sign.
* g10/decrypt.c (decrypt_message_fd): Use gnupg_fd_t. * g10/plaintext.c (hash_datafile_by_fd): Use gnupg_fd_t. * g10/main.h: Fix the declarations. * g10/mainproc.c (struct mainproc_context): Use gnupg_fd_t for DATA_FD. (proc_compressed_cb, proc_signature_packets): Follow the change. (proc_signature_packets_by_fd): Use gnupg_fd_t. * g10/packet.h: Fix the declaration. -- GnuPG-bug-id: 6580 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'g10/decrypt.c')
-rw-r--r--g10/decrypt.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/g10/decrypt.c b/g10/decrypt.c
index cb9e36a93..26081ed1b 100644
--- a/g10/decrypt.c
+++ b/g10/decrypt.c
@@ -100,7 +100,8 @@ decrypt_message (ctrl_t ctrl, const char *filename)
/* Same as decrypt_message but takes a file descriptor for input and
output. */
gpg_error_t
-decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
+decrypt_message_fd (ctrl_t ctrl, gnupg_fd_t input_fd,
+ gnupg_fd_t output_fd)
{
#ifdef HAVE_W32_SYSTEM
/* No server mode yet. */
@@ -113,6 +114,7 @@ decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
IOBUF fp;
armor_filter_context_t *afx = NULL;
progress_filter_context_t *pfx;
+ es_syshd_t syshd;
if (opt.outfp)
return gpg_error (GPG_ERR_BUG);
@@ -138,13 +140,20 @@ decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
return err;
}
- opt.outfp = es_fdopen_nc (output_fd, "wb");
+#ifdef HAVE_W32_SYSTEM
+ syshd.type = ES_SYSHD_HANDLE;
+ syshd.u.handle = output_fd;
+#else
+ syshd.type = ES_SYSHD_FD;
+ syshd.u.fd = output_fd;
+#endif
+ opt.outfp = es_sysopen_nc (&syshd, "w");
if (!opt.outfp)
{
char xname[64];
err = gpg_error_from_syserror ();
- snprintf (xname, sizeof xname, "[fd %d]", output_fd);
+ snprintf (xname, sizeof xname, "[fd %d]", (int)(intprt_t)output_fd);
log_error (_("can't open '%s': %s\n"), xname, gpg_strerror (err));
iobuf_close (fp);
release_progress_context (pfx);