X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/95278287f4e1eeaf5d96749d6fc9bfc53fb400d0..d27daedb6a0bf672508072100f20233d08ccf0e0:/apt-pkg/pkgcachegen.cc diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 89b4c4bae..61f7a1124 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -125,7 +125,7 @@ pkgCacheGenerator::pkgCacheGenerator(DynamicMMap *pMap,OpProgress *Prog) : advoid a problem during a crash */ pkgCacheGenerator::~pkgCacheGenerator() { - if (_error->PendingError() == true) + if (_error->PendingError() == true || Map.validData() == false) return; if (Map.Sync() == false) return; @@ -1070,7 +1070,8 @@ bool pkgCacheListParser::NewProvides(pkgCache::VerIterator &Ver, // We do not add self referencing provides if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() || - (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0))) + (PkgArch == "all" && strcmp((Cache.StrP + Cache.HeaderP->Architecture), Ver.ParentPkg().Arch()) == 0)) && + (Version.empty() || Version == Ver.VerStr())) return true; // Locate the target package @@ -1306,6 +1307,8 @@ static bool CheckValidity(const string &CacheFile, // Map it FileFd CacheF(CacheFile,FileFd::ReadOnly); std::unique_ptr Map(new MMap(CacheF,0)); + if (unlikely(Map->validData()) == false) + return false; pkgCache Cache(Map.get()); if (_error->PendingError() || Map->Size() == 0) { @@ -1433,7 +1436,6 @@ static bool BuildCache(pkgCacheGenerator &Gen, pkgSourceList const * const List, FileIterator const Start, FileIterator const End) { - std::vector Files; bool mergeFailure = false; auto const indexFileMerge = [&](pkgIndexFile * const I) { @@ -1539,6 +1541,8 @@ static bool loadBackMMapFromFile(std::unique_ptr &Gen, std::unique_ptr &Map, OpProgress * const Progress, std::string const &FileName) { Map.reset(CreateDynamicMMap(NULL, 0)); + if (unlikely(Map->validData()) == false) + return false; FileFd CacheF(FileName, FileFd::ReadOnly); if (CacheF.IsOpen() == false || CacheF.Failed()) return false; @@ -1553,7 +1557,7 @@ static bool loadBackMMapFromFile(std::unique_ptr &Gen, Gen.reset(new pkgCacheGenerator(Map.get(),Progress)); return true; } -APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, +bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, MMap **OutMap, bool AllowMem) { return pkgCacheGenerator::MakeStatusCache(List, &Progress, OutMap, AllowMem); } bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress, @@ -1628,6 +1632,8 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress // At this point we know we need to construct something, so get storage ready std::unique_ptr Map(CreateDynamicMMap(NULL, 0)); + if (unlikely(Map->validData()) == false) + return false; if (Debug == true) std::clog << "Open memory Map (not filebased)" << std::endl; @@ -1706,7 +1712,7 @@ public: ScopedErrorMerge() { _error->PushToStack(); } ~ScopedErrorMerge() { _error->MergeWithStack(); } }; -APT_DEPRECATED bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) +bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap) { return pkgCacheGenerator::MakeOnlyStatusCache(&Progress, OutMap); } bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **OutMap) { @@ -1716,6 +1722,8 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O ScopedErrorMerge sem; std::unique_ptr Map(CreateDynamicMMap(NULL, 0)); + if (unlikely(Map->validData()) == false) + return false; map_filesize_t CurrentSize = 0; map_filesize_t TotalSize = 0; TotalSize = ComputeSize(NULL, Files.begin(), Files.end());