aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2023-07-13 05:35:00 +0000
committerNIIBE Yutaka <[email protected]>2023-07-13 05:37:20 +0000
commitcf270b0d3028a0837a69bb9f9b2ba13dafd536a4 (patch)
tree8a533e2246f96fca31a837fc8a59de047921444a
parentsm: Use open_stream_nc for do_listkeys. (diff)
downloadgnupg-cf270b0d3028a0837a69bb9f9b2ba13dafd536a4.tar.gz
gnupg-cf270b0d3028a0837a69bb9f9b2ba13dafd536a4.zip
sm: Fix open_es_fread and open_es_fwrite for gnupg_fd_t.
* sm/gpgsm.c (open_es_fread, open_es_fwrite): Use gnupg_fd_t and open_stream_nc. -- GnuPG-bug-id: 6580 Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--sm/gpgsm.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index ce977413d..f23c63e0b 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -2327,7 +2327,7 @@ open_es_fread (const char *filename, const char *mode)
estream_t fp;
if (filename[0] == '-' && !filename[1])
- fd = fileno (stdin);
+ return es_fpopen_nc (stdin, mode);
else
fd = check_special_filename (filename, 0, 0);
if (fd != -1)
@@ -2335,7 +2335,8 @@ open_es_fread (const char *filename, const char *mode)
fp = es_fdopen_nc (fd, mode);
if (!fp)
{
- log_error ("es_fdopen(%d) failed: %s\n", fd, strerror (errno));
+ log_error ("es_fdopen(%d) failed: %s\n", (int)(intptr_t)fd,
+ strerror (errno));
gpgsm_exit (2);
}
return fp;
@@ -2357,23 +2358,24 @@ open_es_fread (const char *filename, const char *mode)
static estream_t
open_es_fwrite (const char *filename)
{
- int fd;
+ gnupg_fd_t fd;
estream_t fp;
if (filename[0] == '-' && !filename[1])
{
fflush (stdout);
- fp = es_fdopen_nc (fileno(stdout), "wb");
+ fp = es_fpopen_nc (stdout, "wb");
return fp;
}
- fd = check_special_filename (filename, 1, 0);
- if (fd != -1)
+ fd = gnupg_check_special_filename (filename);
+ if (fd != GNUPG_INVALID_FD)
{
- fp = es_fdopen_nc (fd, "wb");
+ fp = open_stream_nc (fd, "wb");
if (!fp)
{
- log_error ("es_fdopen(%d) failed: %s\n", fd, strerror (errno));
+ log_error ("es_fdopen(%d) failed: %s\n",
+ (int)(intptr_t)fd, strerror (errno));
gpgsm_exit (2);
}
return fp;