mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-10 21:38:50 +01:00
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 <gniibe@fsij.org>
This commit is contained in:
parent
b4246422f4
commit
9c12c2f91c
18
sm/gpgsm.c
18
sm/gpgsm.c
@ -2363,7 +2363,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 = gnupg_check_special_filename (filename);
|
||||
if (fd != GNUPG_INVALID_FD)
|
||||
@ -2371,7 +2371,8 @@ open_es_fread (const char *filename, const char *mode)
|
||||
fp = open_stream_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;
|
||||
@ -2393,23 +2394,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;
|
||||
|
Loading…
Reference in New Issue
Block a user