]> git.saurik.com Git - apt.git/commitdiff
gpgv: Flush the files before checking for errors
authorJulian Andres Klode <jak@debian.org>
Tue, 6 Dec 2016 08:35:11 +0000 (09:35 +0100)
committerJulian Andres Klode <jak@debian.org>
Thu, 8 Dec 2016 14:19:30 +0000 (15:19 +0100)
This is a follow up to the previous issue where we did not check
if getline() returned -1 due to an end of file or due to an error
like memory allocation, treating both as end of file.

Here we ensure that we also handle buffered writes correctly by
flushing the files before checking for any errors in our error
stack.

Buffered writes themselves were introduced in 1.1.9, but the
function was never called with a buffered file from inside
apt until commit 46c4043d741cb2c1d54e7f5bfaa234f1b7580f6c
which was first released with apt 1.2.10. The function is
public, though, so fixing this is a good idea anyway.

Affected: >= 1.1.9

apt-pkg/contrib/gpgv.cc

index 7d493fdf6f203bd73ece8a64f5fc49a1ca7a6127..b6c4b6e0898ba74ea06914f59032b89d37f2bbf4 100644 (file)
@@ -381,6 +381,12 @@ bool SplitClearSignedFile(std::string const &InFile, FileFd * const ContentFile,
    if (buf != NULL)
       free(buf);
 
+   // Flush the files. Errors will be checked below.
+   if (SignatureFile != nullptr)
+      SignatureFile->Flush();
+   if (ContentFile != nullptr)
+      ContentFile->Flush();
+
    // An error occured during reading - propagate it up
    bool const hasErrored = _error->PendingError();
    _error->MergeWithStack();