[git] GnuPG - branch, master, updated. gnupg-2.2.7-217-g50b02db

by NIIBE Yutaka cvs at cvs.gnupg.org
Tue Oct 2 07:30:27 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  50b02dba2060a8969da47b18d9c0ecdccbd30db4 (commit)
      from  0cb65564e022fface5ada4de8e0c2c4c3d0ac8ad (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 50b02dba2060a8969da47b18d9c0ecdccbd30db4
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Tue Oct 2 14:22:24 2018 +0900

    common: Fix gnupg_reopen_std.
    
    * common/sysutils.c (gnupg_reopen_std): Use fcntl instead of fstat.
    
    --
    
    When gpg was invoked by a Perl web application on FreeBSD, fstat in
    gnupg_reopen_std failed with EBADF.  Using fcntl, which is considered
    lighter than fstat, it works fine.  Since uur purpose is to check if
    file descriptor is valid or not, lighter operation is better.
    
    Reported-by: Marcin Gryszkalis <mg at fork.pl>
    Signed-off-by: NIIBE Yutaka <gniibe at fsij.org>

diff --git a/common/sysutils.c b/common/sysutils.c
index 55a7ee9..0a3dc2e 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -551,14 +551,13 @@ gnupg_tmpfile (void)
 void
 gnupg_reopen_std (const char *pgmname)
 {
-#if defined(HAVE_STAT) && !defined(HAVE_W32_SYSTEM)
-  struct stat statbuf;
+#ifdef F_GETFD
   int did_stdin = 0;
   int did_stdout = 0;
   int did_stderr = 0;
   FILE *complain;
 
-  if (fstat (STDIN_FILENO, &statbuf) == -1 && errno ==EBADF)
+  if (fcntl (STDIN_FILENO, F_GETFD) == -1 && errno ==EBADF)
     {
       if (open ("/dev/null",O_RDONLY) == STDIN_FILENO)
 	did_stdin = 1;
@@ -566,7 +565,7 @@ gnupg_reopen_std (const char *pgmname)
 	did_stdin = 2;
     }
 
-  if (fstat (STDOUT_FILENO, &statbuf) == -1 && errno == EBADF)
+  if (fcntl (STDOUT_FILENO, F_GETFD) == -1 && errno == EBADF)
     {
       if (open ("/dev/null",O_WRONLY) == STDOUT_FILENO)
 	did_stdout = 1;
@@ -574,7 +573,7 @@ gnupg_reopen_std (const char *pgmname)
 	did_stdout = 2;
     }
 
-  if (fstat (STDERR_FILENO, &statbuf)==-1 && errno==EBADF)
+  if (fcntl (STDERR_FILENO, F_GETFD)==-1 && errno==EBADF)
     {
       if (open ("/dev/null", O_WRONLY) == STDERR_FILENO)
 	did_stderr = 1;
@@ -607,7 +606,7 @@ gnupg_reopen_std (const char *pgmname)
 
   if (did_stdin == 2 || did_stdout == 2 || did_stderr == 2)
     exit (3);
-#else /* !(HAVE_STAT && !HAVE_W32_SYSTEM) */
+#else /* !F_GETFD */
   (void)pgmname;
 #endif
 }

-----------------------------------------------------------------------

Summary of changes:
 common/sysutils.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list