From 2d71f8c24d490b5a3773821264124f0ed5c9a9d2 Mon Sep 17 00:00:00 2001 From: Jaywalker Date: Tue, 6 Feb 2018 23:51:41 -0600 Subject: Fixed system() using coolstar's patch and added other required patches --- apt-pkg/contrib/gpgv.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib/gpgv.cc') 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_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); } -- cgit v1.2.3