X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/d0f1646ae06ca5710b015662b9244e277dce73fa..7b15b702b1f908595a2ae484117746587f8e03aa:/methods/gpgv.cc diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 3ad3e8d84..25ba0d063 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -1,9 +1,11 @@ +#include + #include #include #include #include #include -#include +#include #include #include @@ -12,9 +14,13 @@ #include #include #include - #include +#include + +using std::string; +using std::vector; + #define GNUPGPREFIX "[GNUPG:]" #define GNUPGBADSIG "[GNUPG:] BADSIG" #define GNUPGNOPUBKEY "[GNUPG:] NO_PUBKEY" @@ -92,8 +98,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++; }