*** apt-0.7.20.2/cmdline/apt-cache.cc 2009-02-07 17:09:35.000000000 +0200
--- apt-0.7.20.2-rhel/cmdline/apt-cache.cc 2010-01-08 20:21:29.000000000 +0200
***************
*** 1208,1214 ****
pkgCache::VerFileIterator Vf = V.FileList();
for (; Vf.end() == false; Vf++)
if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0)
! break;
if (Vf.end() == true)
Vf = V.FileList();
--- 1208,1214 ----
pkgCache::VerFileIterator Vf = V.FileList();
for (; Vf.end() == false; Vf++)
if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0)
! break;
if (Vf.end() == true)
Vf = V.FileList();
***************
*** 1233,1238 ****
--- 1233,1245 ----
// Get a pointer to start of Description field
const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
+ // HH: Bug fix. If descriptions are not found quit now to prevent crash
+ if (DescP == NULL)
+ {
+ cout << "E: Malformed packages inserted into cache. Description field missing!";
+ delete [] Buffer;
+ return false;
+ }
// Write all but Description
if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer))
***************
*** 1282,1287 ****
--- 1289,1300 ----
bool Search(CommandLine &CmdL)
{
pkgCache &Cache = *GCache;
+ // HH: Bug fix. No need to do anything if no packages
+ if (Cache.HeaderP->PackageCount == 0)
+ {
+ return true;
+ }
+
bool ShowFull = _config->FindB("APT::Cache::ShowFull",false);
bool NamesOnly = _config->FindB("APT::Cache::NamesOnly",false);
unsigned NumPatterns = CmdL.FileSize() -1;
***************
*** 1316,1322 ****
}
ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1];
! memset(DFList,0,sizeof(*DFList)*Cache.HeaderP->PackageCount+1);
// Map versions that we want to write out onto the VerList array.
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
--- 1329,1336 ----
}
ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1];
! // HH: Bug fix. Memset all the memory
! memset(DFList, 0, sizeof(*DFList) * (Cache.HeaderP->PackageCount + 1));
// Map versions that we want to write out onto the VerList array.
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
***************
*** 1416,1423 ****
pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
if (Pkg.end() == true)
{
! _error->Warning(_("Unable to locate package %s"),*I);
! continue;
}
++found;
--- 1430,1437 ----
pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
if (Pkg.end() == true)
{
! _error->Warning(_("Unable to locate package %s"),*I);
! continue;
}
++found;
***************
*** 1425,1444 ****
// Find the proper version to use.
if (_config->FindB("APT::Cache::AllVersions","true") == true)
{
! pkgCache::VerIterator V;
! for (V = Pkg.VersionList(); V.end() == false; V++)
! {
! if (DisplayRecord(V) == false)
! return false;
! }
}
else
{
! pkgCache::VerIterator V = Plcy.GetCandidateVer(Pkg);
! if (V.end() == true || V.FileList().end() == true)
! continue;
! if (DisplayRecord(V) == false)
! return false;
}
}
--- 1439,1458 ----
// Find the proper version to use.
if (_config->FindB("APT::Cache::AllVersions","true") == true)
{
! pkgCache::VerIterator V;
! for (V = Pkg.VersionList(); V.end() == false; V++)
! {
! if (DisplayRecord(V) == false)
! return false;
! }
}
else
{
! pkgCache::VerIterator V = Plcy.GetCandidateVer(Pkg);
! if (V.end() == true || V.FileList().end() == true)
! continue;
! if (DisplayRecord(V) == false)
! return false;
}
}