diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2013-03-15 14:49:05 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2013-03-15 14:49:05 +0100 |
commit | b38bb727530a7e836689ef100b07926522066986 (patch) | |
tree | ab277b22eb42e6a410a1ae8915bb1761ce8162f2 | |
parent | 99ed26d32226f0dffe5a37fb78c5588f9d9ecfd5 (diff) |
don't close stdout/stderr if it is also the statusfd
-rw-r--r-- | apt-pkg/contrib/gpgv.cc | 21 | ||||
-rw-r--r-- | debian/changelog | 1 |
2 files changed, 12 insertions, 10 deletions
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<config.h> -#include <iostream> -#include <sstream> -#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> + +#include <vector> #include <apt-pkg/error.h> #include <apt-pkg/strutl.h> @@ -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<string>::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 <kalnischkies@gmail.com> Fri, 15 Mar 2013 14:15:43 +0100 |