diff options
author | Steve Langasek <steve.langasek@canonical.com> | 2012-01-28 11:57:27 -0800 |
---|---|---|
committer | Steve Langasek <steve.langasek@canonical.com> | 2012-01-28 11:57:27 -0800 |
commit | e7a0af555a1a12dce01d0928b0262ec450c34bb0 (patch) | |
tree | cb20c92b9376c66d44046df486b124dfe431ff69 | |
parent | a5da6449447ee7f14fc0e271b6fe07739387ba8c (diff) |
apt-pkg/algorithms.{cc,h}: use an int to represent resolver scores, not
a signed short, because large upgrades can result in an overflow for
core packages. Thanks again to Colin Watson. Closes: #657732,
LP: #917173.
-rw-r--r-- | apt-pkg/algorithms.cc | 30 | ||||
-rw-r--r-- | apt-pkg/algorithms.h | 2 | ||||
-rw-r--r-- | debian/changelog | 4 |
3 files changed, 20 insertions, 16 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index 7a9586ca0..c337ace87 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -475,7 +475,7 @@ pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : Cache(*pCache) { // Allocate memory unsigned long Size = Cache.Head().PackageCount; - Scores = new signed short[Size]; + Scores = new int[Size]; Flags = new unsigned char[Size]; memset(Flags,0,sizeof(*Flags)*Size); @@ -515,20 +515,20 @@ void pkgProblemResolver::MakeScores() memset(Scores,0,sizeof(*Scores)*Size); // Important Required Standard Optional Extra - signed short PrioMap[] = { + int PrioMap[] = { 0, - (signed short) _config->FindI("pkgProblemResolver::Scores::Important",3), - (signed short) _config->FindI("pkgProblemResolver::Scores::Required",2), - (signed short) _config->FindI("pkgProblemResolver::Scores::Standard",1), - (signed short) _config->FindI("pkgProblemResolver::Scores::Optional",-1), - (signed short) _config->FindI("pkgProblemResolver::Scores::Extra",-2) + _config->FindI("pkgProblemResolver::Scores::Important",3), + _config->FindI("pkgProblemResolver::Scores::Required",2), + _config->FindI("pkgProblemResolver::Scores::Standard",1), + _config->FindI("pkgProblemResolver::Scores::Optional",-1), + _config->FindI("pkgProblemResolver::Scores::Extra",-2) }; - signed short PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100); - signed short PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1); - signed short PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1); - signed short PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1); - signed short AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000); - signed short AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000); + int PrioEssentials = _config->FindI("pkgProblemResolver::Scores::Essentials",100); + int PrioInstalledAndNotObsolete = _config->FindI("pkgProblemResolver::Scores::NotObsolete",1); + int PrioDepends = _config->FindI("pkgProblemResolver::Scores::Depends",1); + int PrioRecommends = _config->FindI("pkgProblemResolver::Scores::Recommends",1); + int AddProtected = _config->FindI("pkgProblemResolver::Scores::AddProtected",10000); + int AddEssential = _config->FindI("pkgProblemResolver::Scores::AddEssential",5000); if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true) clog << "Settings used to calculate pkgProblemResolver::Scores::" << endl @@ -550,7 +550,7 @@ void pkgProblemResolver::MakeScores() if (Cache[I].InstallVer == 0) continue; - signed short &Score = Scores[I->ID]; + int &Score = Scores[I->ID]; /* This is arbitrary, it should be high enough to elevate an essantial package above most other packages but low enough @@ -588,7 +588,7 @@ void pkgProblemResolver::MakeScores() } // Copy the scores to advoid additive looping - SPtrArray<signed short> OldScores = new signed short[Size]; + SPtrArray<int> OldScores = new int[Size]; memcpy(OldScores,Scores,sizeof(*Scores)*Size); /* Now we cause 1 level of dependency inheritance, that is we add the diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h index 185d11e96..37eacf1f8 100644 --- a/apt-pkg/algorithms.h +++ b/apt-pkg/algorithms.h @@ -96,7 +96,7 @@ class pkgProblemResolver /*{{{*/ enum Flags {Protected = (1 << 0), PreInstalled = (1 << 1), Upgradable = (1 << 2), ReInstateTried = (1 << 3), ToRemove = (1 << 4)}; - signed short *Scores; + int *Scores; unsigned char *Flags; bool Debug; diff --git a/debian/changelog b/debian/changelog index 9bd5453e2..69f272750 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,10 @@ apt (0.8.16~exp12ubuntu1) UNRELEASED; urgency=low * apt-pkg/algorithms.cc: iterate Breaks the same way as Conflicts, so that we resolve virtual package Breaks more effectively. Thanks to Colin Watson for the patch. Closes: #657695, LP: #922485. + * apt-pkg/algorithms.{cc,h}: use an int to represent resolver scores, not + a signed short, because large upgrades can result in an overflow for + core packages. Thanks again to Colin Watson. Closes: #657732, + LP: #917173. -- Steve Langasek <steve.langasek@ubuntu.com> Sat, 28 Jan 2012 11:40:53 -0800 |