summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/gpgv.cc
diff options
context:
space:
mode:
authorJaywalker <jwilliams@nsllc.com>2018-02-06 23:51:41 -0600
committerJaywalker <jwilliams@nsllc.com>2018-02-06 23:51:41 -0600
commit2d71f8c24d490b5a3773821264124f0ed5c9a9d2 (patch)
tree3b77d056cae38d88a93aeb691d9c5364bedb4b30 /apt-pkg/contrib/gpgv.cc
parent3bfcf8ca7023843a9b12de8e58bccab32b4c1a43 (diff)
Fixed system() using coolstar's patch and added other required patches
Diffstat (limited to 'apt-pkg/contrib/gpgv.cc')
-rw-r--r--apt-pkg/contrib/gpgv.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 856d56bc1..fa1055556 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -252,7 +252,34 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
{
if (statusfd != -1)
dup2(fd[1], statusfd);
- execvp(Args[0], (char **) &Args[0]);
+ //I don't really C++, so I hope this is the best way to make a std::vector into a space separated C-string.
+ char *fullCmd = NULL;
+ char *tmpCmd = NULL;
+ bool firstTime = true;
+ int size = 0;
+ for (std::vector<const char *>::const_iterator a = Args.begin(); a != Args.end(); ++a) {
+ size = strlen(*a) + 1; //Plus one for \0
+ if (fullCmd != NULL) {
+ size += strlen(fullCmd) + 1; //Plus one for space
+ if (tmpCmd != NULL)
+ free(tmpCmd);
+ tmpCmd = (char *)malloc(sizeof(char) * (strlen(fullCmd) + 1));
+ strcpy(tmpCmd, fullCmd);
+ free(fullCmd);
+ }
+ fullCmd = (char *)malloc(sizeof(char) * size);
+ if (tmpCmd == NULL)
+ strcpy(fullCmd, *a);
+ else
+ sprintf(fullCmd, "%s %s\0", tmpCmd, *a);
+ }
+ if (tmpCmd != NULL)
+ free(tmpCmd);
+ if (fullCmd != NULL) {
+ RunCmd(fullCmd);
+ free(fullCmd);
+ }
+ //execvp(Args[0], (char **) &Args[0]);
apt_error(std::cerr, statusfd, fd, "Couldn't execute %s to check %s", Args[0], File.c_str());
local_exit(EINTERNAL);
}