Browse Source

* apt-pkg/pkgcache.cc:
- Check that cache is at least CacheFileSize bytes large (LP: #16467)

Julian Andres Klode 15 years ago
parent
commit
7d79339f81
2 changed files with 5 additions and 0 deletions
  1. 3 0
      apt-pkg/pkgcache.cc
  2. 2 0
      debian/changelog

+ 3 - 0
apt-pkg/pkgcache.cc

@@ -157,6 +157,9 @@ bool pkgCache::ReMap(bool const &Errorchecks)
        HeaderP->CheckSizes(DefHeader) == false)
       return _error->Error(_("The package cache file is an incompatible version"));
 
+   if (Map.Size() < HeaderP->CacheFileSize)
+      return _error->Error(_("The package cache file is corrupted, it is too small"));
+
    // Locate our VS..
    if (HeaderP->VerSysName == 0 ||
        (VS = pkgVersioningSystem::GetVS(StrP + HeaderP->VerSysName)) == 0)

+ 2 - 0
debian/changelog

@@ -4,6 +4,8 @@ apt (0.8.16~exp4) UNRELEASED; urgency=low
     - [ABI break] Add pkgCache::Header::CacheFileSize, storing the cache size
   * apt-pkg/pkgcachegen.cc:
     - Write the file size to the cache
+  * apt-pkg/pkgcache.cc:
+    - Check that cache is at least CacheFileSize bytes large (LP: #16467)
 
  -- Julian Andres Klode <jak@debian.org>  Wed, 20 Jul 2011 16:23:55 +0200