From: David Kalnischkies Date: Fri, 15 Mar 2013 13:49:05 +0000 (+0100) Subject: don't close stdout/stderr if it is also the statusfd X-Git-Tag: 0.9.8~20^2^2~7^2~3 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/b38bb727530a7e836689ef100b07926522066986 don't close stdout/stderr if it is also the statusfd --- diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc index 9760bd21f..94a1f8778 100644 --- a/apt-pkg/contrib/gpgv.cc +++ b/apt-pkg/contrib/gpgv.cc @@ -2,14 +2,13 @@ // Include Files /*{{{*/ #include -#include -#include -#include +#include +#include #include #include #include -#include -#include + +#include #include #include @@ -85,12 +84,12 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, Args.push_back(gpgvpath.c_str()); Args.push_back("--ignore-time-conflict"); + char statusfdstr[10]; if (statusfd != -1) { Args.push_back("--status-fd"); - char fd[10]; - snprintf(fd, sizeof(fd), "%i", statusfd); - Args.push_back(fd); + snprintf(statusfdstr, sizeof(fd), "%i", statusfd); + Args.push_back(statusfdstr); } for (vector::const_iterator K = keyrings.begin(); @@ -131,8 +130,10 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG, int const nullfd = open("/dev/null", O_RDONLY); close(fd[0]); // Redirect output to /dev/null; we read from the status fd - dup2(nullfd, STDOUT_FILENO); - dup2(nullfd, STDERR_FILENO); + if (statusfd != STDOUT_FILENO) + dup2(nullfd, STDOUT_FILENO); + if (statusfd != STDERR_FILENO) + dup2(nullfd, STDERR_FILENO); // Redirect the pipe to the status fd (3) dup2(fd[1], statusfd); diff --git a/debian/changelog b/debian/changelog index bd4116406..0423cefa6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,7 @@ apt (0.9.7.9) UNRELEASED; urgency=low * apt-pkg/contrib/gpgv.cc: - ExecGPGV is a method which should never return, so mark it as such and fix the inconsistency of returning in error cases + - don't close stdout/stderr if it is also the statusfd -- David Kalnischkies Fri, 15 Mar 2013 14:15:43 +0100