]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
Fix buffer overflow in debListParser::VersionHash()
[apt.git] / apt-pkg / contrib / fileutl.cc
index 9990b753ab365bccf4ec4861b44919a3eb5e5ea0..94d1432cfa908bc14261ea5f08b48f45bfcccd47 100644 (file)
@@ -1535,7 +1535,7 @@ public:
         return false;
 
       unsigned int flags = (Mode & (FileFd::WriteOnly|FileFd::ReadOnly));
         return false;
 
       unsigned int flags = (Mode & (FileFd::WriteOnly|FileFd::ReadOnly));
-      if (backend.OpenDescriptor(iFd, flags) == false)
+      if (backend.OpenDescriptor(iFd, flags, FileFd::None, true) == false)
         return false;
 
       // Write the file header
         return false;
 
       // Write the file header
@@ -1646,6 +1646,11 @@ public:
         res = LZ4F_freeDecompressionContext(dctx);
         dctx = nullptr;
       }
         res = LZ4F_freeDecompressionContext(dctx);
         dctx = nullptr;
       }
+      if (backend.IsOpen())
+      {
+        backend.Close();
+        filefd->iFd = -1;
+      }
 
       return LZ4F_isError(res) == false;
    }
 
       return LZ4F_isError(res) == false;
    }
@@ -1978,6 +1983,11 @@ public:
    virtual bool InternalClose(std::string const &) APT_OVERRIDE
    {
       bool Ret = true;
    virtual bool InternalClose(std::string const &) APT_OVERRIDE
    {
       bool Ret = true;
+      if (filefd->iFd != -1)
+      {
+        close(filefd->iFd);
+        filefd->iFd = -1;
+      }
       if (compressor_pid > 0)
         Ret &= ExecWait(compressor_pid, "FileFdCompressor", true);
       compressor_pid = -1;
       if (compressor_pid > 0)
         Ret &= ExecWait(compressor_pid, "FileFdCompressor", true);
       compressor_pid = -1;