]> git.saurik.com Git - apt.git/commitdiff
fail in CopyFile if the FileFds have error flag set
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 9 Jun 2013 16:33:48 +0000 (18:33 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sun, 9 Jun 2013 16:49:55 +0000 (18:49 +0200)
Testing for global PendingErrors in users of CopyFile is incorrect
in so far as unrelated errors will prevent us from copying perfectly
fine files and checking for the validity of the files is just better
in CopyFiles as it already checks if files are at least opened.

Add also a higher-level error message to the error stack if it fails.

apt-pkg/contrib/fileutl.cc
apt-pkg/indexcopy.cc
debian/changelog

index 7c3a302e266f5354aa5a20d5cd957523b47fdd97..0f88923cfacfe9f3408e191f417252faf0313329 100644 (file)
@@ -184,7 +184,8 @@ bool RunScripts(const char *Cnf)
 /* The caller is expected to set things so that failure causes erasure */
 bool CopyFile(FileFd &From,FileFd &To)
 {
-   if (From.IsOpen() == false || To.IsOpen() == false)
+   if (From.IsOpen() == false || To.IsOpen() == false ||
+        From.Failed() == true || To.Failed() == true)
       return false;
    
    // Buffered copy between fds
index 0e36b3ded7cbf60d4f8d5cc3a75dfe85344863ff..1d61b974d3c0f3edbeef0a3b086b03d295935a93 100644 (file)
@@ -544,11 +544,9 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName,         /*{{{*/
       FileFd Rel;
       Target.Open(TargetF,FileFd::WriteAtomic);
       Rel.Open(prefix + file,FileFd::ReadOnly);
-      if (_error->PendingError() == true)
-        return false;
       if (CopyFile(Rel,Target) == false)
-        return false;
-   
+        return _error->Error("Copying of '%s' for '%s' from '%s' failed", file.c_str(), CDName.c_str(), prefix.c_str());
+
       return true;
 }
                                                                        /*}}}*/
index 42a8e540e5e2ab53544097858217817ca69f25e9..cde0aba2f4829c99c2de968b834cd757fb0c8dea 100644 (file)
@@ -13,6 +13,7 @@ apt (0.9.8.3) UNRELEASED; urgency=low
   * set Fail flag in FileFd on all errors consistently
   * don't explicitly init ExtractTar InFd with invalid fd
   * OpenDescriptor should autoclose fd always on error (Closes: #704608)
+  * fail in CopyFile if the FileFds have error flag set
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Sun, 09 Jun 2013 15:06:24 +0200