summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2016-12-06 09:35:11 +0100
committerJulian Andres Klode <jak@debian.org>2016-12-08 15:28:03 +0100
commit7027ca0134469b35468af8666528f6ef6b38bc31 (patch)
treedb18ca2f227cf4012367146fb59beb89f4a2fc18
parent0bbbabb1b961b3b6541e7fdc8061fe6f282eafad (diff)
gpgv: Flush the files before checking for errors
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 (cherry picked from commit 6212ee84a517ed68217429022bd45c108ecf9f85) (cherry picked from commit e115da452632a024a2885fea27a6c2c5145282b1)
-rw-r--r--apt-pkg/contrib/gpgv.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 7e7b3ac80..a5f2441b7 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -329,6 +329,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();