aboutsummaryrefslogtreecommitdiffstats
path: root/g10/encrypt.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2023-07-05 00:57:10 +0000
committerNIIBE Yutaka <[email protected]>2023-07-05 01:05:31 +0000
commit2c2516f03a28156d58b8da4c05f716095eab8957 (patch)
tree934620247446c830496393ac3650730cf3c6f58a /g10/encrypt.c
parentgpg: Use gnupg_fd_t for open_outfile. (diff)
downloadgnupg-2c2516f03a28156d58b8da4c05f716095eab8957.tar.gz
gnupg-2c2516f03a28156d58b8da4c05f716095eab8957.zip
gpg: Use gnupg_fd_t for encrypt_crypt and gpg_verify.
* common/iobuf.h (iobuf_fdopen_nc): Use gnupg_t. * common/iobuf.c (iobuf_fdopen_nc): Use gnupg_t. * g10/main.h (encrypt_crypt, gpg_verify): Use gnupg_fd_t. * g10/encrypt.c (encrypt_crypt): Use gnupg_fd_t. (encrypt_crypt_files): Follow the change. * g10/gpg.c (main): Follow the change. * g10/verify.c (gpg_verify): Use gnupg_fd_t. -- GnuPG-bug-id: 6580 Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/encrypt.c')
-rw-r--r--g10/encrypt.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/g10/encrypt.c b/g10/encrypt.c
index 9e42beb82..42ee0b773 100644
--- a/g10/encrypt.c
+++ b/g10/encrypt.c
@@ -764,9 +764,9 @@ write_symkey_enc (STRING2KEY *symkey_s2k, aead_algo_t aead_algo,
* not yet finished server.c.
*/
int
-encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
+encrypt_crypt (ctrl_t ctrl, gnupg_fd_t filefd, const char *filename,
strlist_t remusr, int use_symkey, pk_list_t provided_keys,
- int outputfd)
+ gnupg_fd_t outputfd)
{
iobuf_t inp = NULL;
iobuf_t out = NULL;
@@ -784,7 +784,7 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
PK_LIST pk_list;
int do_compress;
- if (filefd != -1 && filename)
+ if (filefd != GNUPG_INVALID_FD && filename)
return gpg_error (GPG_ERR_INV_ARG); /* Both given. */
do_compress = !!opt.compress_algo;
@@ -815,7 +815,7 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
/* Prepare iobufs. */
#ifdef HAVE_W32_SYSTEM
- if (filefd == -1)
+ if (filefd == GNUPG_INVALID_FD)
inp = iobuf_open (filename);
else
{
@@ -823,7 +823,7 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
gpg_err_set_errno (ENOSYS);
}
#else
- if (filefd == -1)
+ if (filefd == GNUPG_INVALID_FD)
inp = iobuf_open (filename);
else
inp = iobuf_fdopen_nc (filefd, "rb");
@@ -841,7 +841,7 @@ encrypt_crypt (ctrl_t ctrl, int filefd, const char *filename,
char xname[64];
rc = gpg_error_from_syserror ();
- if (filefd != -1)
+ if (filefd != GNUPG_INVALID_FD)
snprintf (xname, sizeof xname, "[fd %d]", filefd);
else if (!filename)
strcpy (xname, "[stdin]");
@@ -1225,7 +1225,8 @@ encrypt_crypt_files (ctrl_t ctrl, int nfiles, char **files, strlist_t remusr)
}
line[strlen(line)-1] = '\0';
print_file_status(STATUS_FILE_START, line, 2);
- rc = encrypt_crypt (ctrl, -1, line, remusr, 0, NULL, -1);
+ rc = encrypt_crypt (ctrl, GNUPG_INVALID_FD, line, remusr,
+ 0, NULL, GNUPG_INVALID_FD);
if (rc)
log_error ("encryption of '%s' failed: %s\n",
print_fname_stdin(line), gpg_strerror (rc) );
@@ -1237,7 +1238,8 @@ encrypt_crypt_files (ctrl_t ctrl, int nfiles, char **files, strlist_t remusr)
while (nfiles--)
{
print_file_status(STATUS_FILE_START, *files, 2);
- if ( (rc = encrypt_crypt (ctrl, -1, *files, remusr, 0, NULL, -1)) )
+ if ((rc = encrypt_crypt (ctrl, GNUPG_INVALID_FD, *files, remusr,
+ 0, NULL, GNUPG_INVALID_FD)))
log_error("encryption of '%s' failed: %s\n",
print_fname_stdin(*files), gpg_strerror (rc) );
write_status( STATUS_FILE_DONE );