632
|
1 |
*** apt-0.7.20.2/cmdline/apt-cache.cc 2009-02-07 17:09:35.000000000 +0200
|
|
2 |
--- apt-0.7.20.2-rhel/cmdline/apt-cache.cc 2010-01-08 20:21:29.000000000 +0200
|
|
3 |
***************
|
|
4 |
*** 1208,1214 ****
|
|
5 |
pkgCache::VerFileIterator Vf = V.FileList();
|
|
6 |
for (; Vf.end() == false; Vf++)
|
|
7 |
if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0)
|
|
8 |
! break;
|
|
9 |
if (Vf.end() == true)
|
|
10 |
Vf = V.FileList();
|
|
11 |
|
|
12 |
--- 1208,1214 ----
|
|
13 |
pkgCache::VerFileIterator Vf = V.FileList();
|
|
14 |
for (; Vf.end() == false; Vf++)
|
|
15 |
if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0)
|
|
16 |
! break;
|
|
17 |
if (Vf.end() == true)
|
|
18 |
Vf = V.FileList();
|
|
19 |
|
|
20 |
***************
|
|
21 |
*** 1233,1238 ****
|
|
22 |
--- 1233,1245 ----
|
|
23 |
|
|
24 |
// Get a pointer to start of Description field
|
|
25 |
const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
|
|
26 |
+ // HH: Bug fix. If descriptions are not found quit now to prevent crash
|
|
27 |
+ if (DescP == NULL)
|
|
28 |
+ {
|
|
29 |
+ cout << "E: Malformed packages inserted into cache. Description field missing!";
|
|
30 |
+ delete [] Buffer;
|
|
31 |
+ return false;
|
|
32 |
+ }
|
|
33 |
|
|
34 |
// Write all but Description
|
|
35 |
if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer))
|
|
36 |
***************
|
|
37 |
*** 1282,1287 ****
|
|
38 |
--- 1289,1300 ----
|
|
39 |
bool Search(CommandLine &CmdL)
|
|
40 |
{
|
|
41 |
pkgCache &Cache = *GCache;
|
|
42 |
+ // HH: Bug fix. No need to do anything if no packages
|
|
43 |
+ if (Cache.HeaderP->PackageCount == 0)
|
|
44 |
+ {
|
|
45 |
+ return true;
|
|
46 |
+ }
|
|
47 |
+
|
|
48 |
bool ShowFull = _config->FindB("APT::Cache::ShowFull",false);
|
|
49 |
bool NamesOnly = _config->FindB("APT::Cache::NamesOnly",false);
|
|
50 |
unsigned NumPatterns = CmdL.FileSize() -1;
|
|
51 |
***************
|
|
52 |
*** 1316,1322 ****
|
|
53 |
}
|
|
54 |
|
|
55 |
ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1];
|
|
56 |
! memset(DFList,0,sizeof(*DFList)*Cache.HeaderP->PackageCount+1);
|
|
57 |
|
|
58 |
// Map versions that we want to write out onto the VerList array.
|
|
59 |
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
|
|
60 |
--- 1329,1336 ----
|
|
61 |
}
|
|
62 |
|
|
63 |
ExDescFile *DFList = new ExDescFile[Cache.HeaderP->PackageCount+1];
|
|
64 |
! // HH: Bug fix. Memset all the memory
|
|
65 |
! memset(DFList, 0, sizeof(*DFList) * (Cache.HeaderP->PackageCount + 1));
|
|
66 |
|
|
67 |
// Map versions that we want to write out onto the VerList array.
|
|
68 |
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
|
|
69 |
***************
|
|
70 |
*** 1416,1423 ****
|
|
71 |
pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
|
|
72 |
if (Pkg.end() == true)
|
|
73 |
{
|
|
74 |
! _error->Warning(_("Unable to locate package %s"),*I);
|
|
75 |
! continue;
|
|
76 |
}
|
|
77 |
|
|
78 |
++found;
|
|
79 |
--- 1430,1437 ----
|
|
80 |
pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
|
|
81 |
if (Pkg.end() == true)
|
|
82 |
{
|
|
83 |
! _error->Warning(_("Unable to locate package %s"),*I);
|
|
84 |
! continue;
|
|
85 |
}
|
|
86 |
|
|
87 |
++found;
|
|
88 |
***************
|
|
89 |
*** 1425,1444 ****
|
|
90 |
// Find the proper version to use.
|
|
91 |
if (_config->FindB("APT::Cache::AllVersions","true") == true)
|
|
92 |
{
|
|
93 |
! pkgCache::VerIterator V;
|
|
94 |
! for (V = Pkg.VersionList(); V.end() == false; V++)
|
|
95 |
! {
|
|
96 |
! if (DisplayRecord(V) == false)
|
|
97 |
! return false;
|
|
98 |
! }
|
|
99 |
}
|
|
100 |
else
|
|
101 |
{
|
|
102 |
! pkgCache::VerIterator V = Plcy.GetCandidateVer(Pkg);
|
|
103 |
! if (V.end() == true || V.FileList().end() == true)
|
|
104 |
! continue;
|
|
105 |
! if (DisplayRecord(V) == false)
|
|
106 |
! return false;
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
--- 1439,1458 ----
|
|
111 |
// Find the proper version to use.
|
|
112 |
if (_config->FindB("APT::Cache::AllVersions","true") == true)
|
|
113 |
{
|
|
114 |
! pkgCache::VerIterator V;
|
|
115 |
! for (V = Pkg.VersionList(); V.end() == false; V++)
|
|
116 |
! {
|
|
117 |
! if (DisplayRecord(V) == false)
|
|
118 |
! return false;
|
|
119 |
! }
|
|
120 |
}
|
|
121 |
else
|
|
122 |
{
|
|
123 |
! pkgCache::VerIterator V = Plcy.GetCandidateVer(Pkg);
|
|
124 |
! if (V.end() == true || V.FileList().end() == true)
|
|
125 |
! continue;
|
|
126 |
! if (DisplayRecord(V) == false)
|
|
127 |
! return false;
|
|
128 |
}
|
|
129 |
}
|
|
130 |
|