summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index c12d8699b..4711372bc 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -100,8 +100,8 @@ bool pkgPolicy::InitDefaults()
}
// Apply the defaults..
- SPtrArray<bool> Fixed = new bool[Cache->HeaderP->PackageFileCount];
- memset(Fixed,0,sizeof(*Fixed)*Cache->HeaderP->PackageFileCount);
+ std::unique_ptr<bool[]> Fixed(new bool[Cache->HeaderP->PackageFileCount]);
+ memset(Fixed.get(),0,sizeof(Fixed[0])*Cache->HeaderP->PackageFileCount);
StatusOverride = false;
for (vector<Pin>::const_iterator I = Defaults.begin(); I != Defaults.end(); ++I)
{
@@ -368,11 +368,12 @@ APT_PURE signed short pkgPolicy::GetPriority(pkgCache::PkgIterator const &Pkg)
return Pins[Pkg->ID].Priority;
return 0;
}
-APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver)
+APT_PURE signed short pkgPolicy::GetPriority(pkgCache::VerIterator const &Ver, bool considerFiles)
{
if (VerPins[Ver->ID].Type != pkgVersionMatch::None)
return VerPins[Ver->ID].Priority;
-
+ if (!considerFiles)
+ return 0;
int priority = std::numeric_limits<int>::min();
for (pkgCache::VerFileIterator file = Ver.FileList(); file.end() == false; file++)
@@ -477,11 +478,18 @@ bool ReadPinFile(pkgPolicy &Plcy,string File)
}
for (; Word != End && isspace(*Word) != 0; Word++);
- short int priority = Tags.FindI("Pin-Priority", 0);
+ int priority = Tags.FindI("Pin-Priority", 0);
+ if (priority < std::numeric_limits<short>::min() ||
+ priority > std::numeric_limits<short>::max() ||
+ _error->PendingError()) {
+ return _error->Error(_("%s: Value %s is outside the range of valid pin priorities (%d to %d)"),
+ File.c_str(), Tags.FindS("Pin-Priority").c_str(),
+ std::numeric_limits<short>::min(),
+ std::numeric_limits<short>::max());
+ }
if (priority == 0)
{
- _error->Warning(_("No priority (or zero) specified for pin"));
- continue;
+ return _error->Error(_("No priority (or zero) specified for pin"));
}
istringstream s(Name);