Просмотр исходного кода

* apt-pkg/contrib/fileutl.cc:
- check that the fd which are closed are valid

David Kalnischkies лет назад: 14
Родитель
Сommit
afb093cd9b
2 измененных файлов с 10 добавлено и 4 удалено
  1. 7 3
      apt-pkg/contrib/fileutl.cc
  2. 3 1
      debian/changelog

+ 7 - 3
apt-pkg/contrib/fileutl.cc

@@ -1065,7 +1065,10 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
       // We don't need the file open - instead let the compressor open it
       // We don't need the file open - instead let the compressor open it
       // as he properly knows better how to efficiently read from 'his' file
       // as he properly knows better how to efficiently read from 'his' file
       if (FileName.empty() == false)
       if (FileName.empty() == false)
+      {
 	 close(iFd);
 	 close(iFd);
+	 iFd = -1;
+      }
    }
    }
 
 
    // Create a data pipe
    // Create a data pipe
@@ -1133,7 +1136,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
       close(Pipe[0]);
       close(Pipe[0]);
    else
    else
       close(Pipe[1]);
       close(Pipe[1]);
-   if (Comp == true || FileName.empty() == true)
+   if ((Comp == true || FileName.empty() == true) && d->compressed_fd != -1)
       close(d->compressed_fd);
       close(d->compressed_fd);
 
 
    return true;
    return true;
@@ -1355,8 +1358,9 @@ bool FileFd::Seek(unsigned long long To)
       if (d->bz2 != NULL)
       if (d->bz2 != NULL)
 	 BZ2_bzclose(d->bz2);
 	 BZ2_bzclose(d->bz2);
 #endif
 #endif
-      close(iFd);
-      iFd = 0;
+      if (iFd != -1)
+	 close(iFd);
+      iFd = -1;
       if (TemporaryFileName.empty() == false)
       if (TemporaryFileName.empty() == false)
 	 iFd = open(TemporaryFileName.c_str(), O_RDONLY);
 	 iFd = open(TemporaryFileName.c_str(), O_RDONLY);
       else if (FileName.empty() == false)
       else if (FileName.empty() == false)

+ 3 - 1
debian/changelog

@@ -1,4 +1,4 @@
-apt (0.9.3) unstable; urgency=low
+apt (0.9.3) UNRELEASED; urgency=low
 
 
   [ David Kalnischkies ]
   [ David Kalnischkies ]
   * apt-pkg/contrib/strutl.cc:
   * apt-pkg/contrib/strutl.cc:
@@ -38,6 +38,8 @@ apt (0.9.3) unstable; urgency=low
     - revert the use of FileFd::Write in OutFdReady as we don't want error
     - revert the use of FileFd::Write in OutFdReady as we don't want error
       reports about EAGAIN here as we retry later. Thanks to YOSHINO Yoshihito
       reports about EAGAIN here as we retry later. Thanks to YOSHINO Yoshihito
       for the report. (Closes: #671721)
       for the report. (Closes: #671721)
+  * apt-pkg/contrib/fileutl.cc:
+    - check that the fd which are closed are valid
 
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 07 May 2012 21:12:23 +0200
  -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 07 May 2012 21:12:23 +0200