]> git.saurik.com Git - apt.git/blobdiff - methods/gpgv.cc
merged lp:~mvo/apt/add-missing-dsc-hashes
[apt.git] / methods / gpgv.cc
index 251bcbc900071c88513fcc926a6f8a4feb32d47d..3f814b9f0aa5c394bca23ecc87e3c0ece12bfaee 100644 (file)
@@ -5,6 +5,8 @@
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/fileutl.h>
 #include <apt-pkg/indexcopy.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/gpgv.h>
 
 #include <utime.h>
 #include <stdio.h>
@@ -17,6 +19,9 @@
 
 #include <apti18n.h>
 
+using std::string;
+using std::vector;
+
 #define GNUPGPREFIX "[GNUPG:]"
 #define GNUPGBADSIG "[GNUPG:] BADSIG"
 #define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY"
@@ -66,19 +71,7 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
    if (pid < 0)
       return string("Couldn't spawn new process") + strerror(errno);
    else if (pid == 0)
-   {
-      _error->PushToStack();
-      bool const success = SigVerify::RunGPGV(outfile, file, 3, fd);
-      if (success == false)
-      {
-        string errmsg;
-        _error->PopMessage(errmsg);
-        _error->RevertToStack();
-        return errmsg;
-      }
-      _error->RevertToStack();
-      exit(111);
-   }
+      ExecGPGV(outfile, file, 3, fd);
    close(fd[1]);
 
    FILE *pipein = fdopen(fd[0], "r");
@@ -94,8 +87,16 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
       // Read a line.  Sigh.
       while ((c = getc(pipein)) != EOF && c != '\n')
       {
-         if (bufferoff == buffersize)
-            buffer = (char *) realloc(buffer, buffersize *= 2);
+        if (bufferoff == buffersize)
+        {
+           char* newBuffer = (char *) realloc(buffer, buffersize *= 2);
+           if (newBuffer == NULL)
+           {
+              free(buffer);
+              return "Couldn't allocate a buffer big enough for reading";
+           }
+           buffer = newBuffer;
+        }
          *(buffer+bufferoff) = c;
          bufferoff++;
       }