From 17019a09e703452735d5af2538654e0532d27d51 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 9 Feb 2012 18:06:29 +0100 Subject: call dpkg --assert-multi-arch with execvp instead of execv --- apt-pkg/aptconfiguration.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index b5ad74831..721b6fd63 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -376,7 +376,7 @@ std::vector const Configuration::getArchitectures(bool const &Cache dup2(nullfd, STDIN_FILENO); dup2(external[1], STDOUT_FILENO); dup2(nullfd, STDERR_FILENO); - execv(Args[0], (char**) &Args[0]); + execvp(Args[0], (char**) &Args[0]); _error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!"); _exit(100); } diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8c63b0c9b..3f9e68210 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -905,7 +905,7 @@ bool pkgDPkgPM::Go(int OutStatusFd) dup2(nullfd, STDIN_FILENO); dup2(nullfd, STDOUT_FILENO); dup2(nullfd, STDERR_FILENO); - execv(Args[0], (char**) &Args[0]); + execvp(Args[0], (char**) &Args[0]); _error->WarningE("dpkgGo", "Can't detect if dpkg supports multi-arch!"); _exit(2); } -- cgit v1.2.3 From dd7233af3e0287566af3946da4b06afd6ccca73a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 10 Feb 2012 15:01:31 +0100 Subject: ensure that architectures are not added multiple times --- apt-pkg/aptconfiguration.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 721b6fd63..4324f0e63 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -392,7 +392,9 @@ std::vector const Configuration::getArchitectures(bool const &Cache if (arch[0] != '\0') { char const* archend = arch; for (; isspace(*archend) == 0 && *archend != '\0'; ++archend); - archs.push_back(string(arch, (archend - arch))); + string a(arch, (archend - arch)); + if (std::find(archs.begin(), archs.end(), a) == archs.end()) + archs.push_back(a); } arch = strtok(NULL, " "); } -- cgit v1.2.3 From 5eb9a474dca2f48a935c234357c3adc9b372423e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 11 Feb 2012 18:54:48 +0100 Subject: correctly ignore already (un)hold packages --- apt-pkg/cacheset.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 91d7eec1c..6f0a0e358 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -191,6 +191,8 @@ public: /*{{{*/ inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; } inline bool operator!=(iterator const &i) const { return _iter != i._iter; }; inline bool operator==(iterator const &i) const { return _iter == i._iter; }; + inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }; + inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }; friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); } }; /*}}}*/ @@ -201,7 +203,9 @@ public: /*{{{*/ bool empty() const { return _cont.empty(); }; void clear() { return _cont.clear(); }; + //FIXME: on ABI break, replace the first with the second without bool void erase(iterator position) { _cont.erase((typename Container::iterator)position); }; + iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }; size_t erase(const pkgCache::PkgIterator x) { return _cont.erase(x); }; void erase(iterator first, iterator last) { _cont.erase(first, last); }; size_t size() const { return _cont.size(); }; @@ -507,6 +511,8 @@ public: /*{{{*/ inline iterator operator++(int) { iterator tmp(*this); operator++(); return tmp; } inline bool operator!=(iterator const &i) const { return _iter != i._iter; }; inline bool operator==(iterator const &i) const { return _iter == i._iter; }; + inline iterator& operator=(iterator const &i) { _iter = i._iter; return *this; }; + inline iterator& operator=(typename Container::iterator const &i) { _iter = i; return *this; }; friend std::ostream& operator<<(std::ostream& out, iterator i) { return operator<<(out, *i); } }; /*}}}*/ @@ -516,7 +522,9 @@ public: /*{{{*/ void insert(const_iterator begin, const_iterator end) { _cont.insert(begin, end); }; bool empty() const { return _cont.empty(); }; void clear() { return _cont.clear(); }; + //FIXME: on ABI break, replace the first with the second without bool void erase(iterator position) { _cont.erase((typename Container::iterator)position); }; + iterator& erase(iterator &position, bool) { return position = _cont.erase((typename Container::iterator)position); }; size_t erase(const pkgCache::VerIterator x) { return _cont.erase(x); }; void erase(iterator first, iterator last) { _cont.erase(first, last); }; size_t size() const { return _cont.size(); }; -- cgit v1.2.3 From dd61e64da1fbae01dc82bab3635c946718cc0eb0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 11 Feb 2012 21:01:35 +0100 Subject: save the universe by not printing messages about apport if a package with this name is not installed (Closes: #619646) --- apt-pkg/deb/dpkgpm.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 3f9e68210..499c3db8a 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1446,6 +1446,12 @@ void pkgDPkgPM::Reset() /* */ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) { + // If apport doesn't exist or isn't installed do nothing + // This e.g. prevents messages in 'universes' without apport + pkgCache::PkgIterator apportPkg = Cache.FindPkg("apport"); + if (apportPkg.end() == true || apportPkg->CurrentVer == 0) + return; + string pkgname, reportfile, srcpkgname, pkgver, arch; string::size_type pos; FILE *report; -- cgit v1.2.3 From fbb2c7e04dd3155983560e0b01a71fd8f62f0b1b Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 11 Feb 2012 22:36:03 +0100 Subject: * apt-pkg/cachefile.cc: - clean up lost atomic cachefiles with 'clean' (Closes: #650513) --- apt-pkg/cachefile.cc | 34 +++++++++++++++++++++ apt-pkg/contrib/fileutl.cc | 74 ++++++++++++++++++++++++++++++++++++++++++++++ apt-pkg/contrib/fileutl.h | 1 + 3 files changed, 109 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index 1b8d91a44..e425c940d 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -178,6 +178,40 @@ void pkgCacheFile::RemoveCaches() unlink(pkgcache.c_str()); if (srcpkgcache.empty() == false && RealFileExists(srcpkgcache) == true) unlink(srcpkgcache.c_str()); + if (pkgcache.empty() == false) + { + std::string cachedir = flNotFile(pkgcache); + std::string cachefile = flNotDir(pkgcache); + if (cachedir.empty() != true && cachefile.empty() != true) + { + cachefile.append("."); + std::vector caches = GetListOfFilesInDir(cachedir, false); + for (std::vector::const_iterator file = caches.begin(); file != caches.end(); ++file) + { + std::string nuke = flNotDir(*file); + if (strncmp(cachefile.c_str(), nuke.c_str(), cachefile.length()) != 0) + continue; + unlink(file->c_str()); + } + } + } + + if (srcpkgcache.empty() == true) + return; + + std::string cachedir = flNotFile(srcpkgcache); + std::string cachefile = flNotDir(srcpkgcache); + if (cachedir.empty() == true || cachefile.empty() == true) + return; + cachefile.append("."); + std::vector caches = GetListOfFilesInDir(cachedir, false); + for (std::vector::const_iterator file = caches.begin(); file != caches.end(); ++file) + { + std::string nuke = flNotDir(*file); + if (strncmp(cachefile.c_str(), nuke.c_str(), cachefile.length()) != 0) + continue; + unlink(file->c_str()); + } } /*}}}*/ // CacheFile::Close - close the cache files /*{{{*/ diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 529e7d655..557ba0ca6 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -454,6 +454,80 @@ std::vector GetListOfFilesInDir(string const &Dir, std::vector c } closedir(D); + if (SortList == true) + std::sort(List.begin(),List.end()); + return List; +} +std::vector GetListOfFilesInDir(string const &Dir, bool SortList) +{ + bool const Debug = _config->FindB("Debug::GetListOfFilesInDir", false); + if (Debug == true) + std::clog << "Accept in " << Dir << " all regular files" << std::endl; + + std::vector List; + + if (DirectoryExists(Dir.c_str()) == false) + { + _error->Error(_("List of files can't be created as '%s' is not a directory"), Dir.c_str()); + return List; + } + + DIR *D = opendir(Dir.c_str()); + if (D == 0) + { + _error->Errno("opendir",_("Unable to read %s"),Dir.c_str()); + return List; + } + + for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) + { + // skip "hidden" files + if (Ent->d_name[0] == '.') + continue; + + // Make sure it is a file and not something else + string const File = flCombine(Dir,Ent->d_name); +#ifdef _DIRENT_HAVE_D_TYPE + if (Ent->d_type != DT_REG) +#endif + { + if (RealFileExists(File.c_str()) == false) + { + if (Debug == true) + std::clog << "Bad file: " << Ent->d_name << " → it is not a real file" << std::endl; + continue; + } + } + + // Skip bad filenames ala run-parts + const char *C = Ent->d_name; + for (; *C != 0; ++C) + if (isalpha(*C) == 0 && isdigit(*C) == 0 + && *C != '_' && *C != '-' && *C != '.') + break; + + // we don't reach the end of the name -> bad character included + if (*C != 0) + { + if (Debug == true) + std::clog << "Bad file: " << Ent->d_name << " → bad character »" << *C << "« in filename" << std::endl; + continue; + } + + // skip filenames which end with a period. These are never valid + if (*(C - 1) == '.') + { + if (Debug == true) + std::clog << "Bad file: " << Ent->d_name << " → Period as last character" << std::endl; + continue; + } + + if (Debug == true) + std::clog << "Accept file: " << Ent->d_name << " in " << Dir << std::endl; + List.push_back(File); + } + closedir(D); + if (SortList == true) std::sort(List.begin(),List.end()); return List; diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index 3814cfe44..1ca41cb7d 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -171,6 +171,7 @@ std::vector GetListOfFilesInDir(std::string const &Dir, std::string bool const &SortList, bool const &AllowNoExt=false); std::vector GetListOfFilesInDir(std::string const &Dir, std::vector const &Ext, bool const &SortList); +std::vector GetListOfFilesInDir(std::string const &Dir, bool SortList); std::string SafeGetCWD(); void SetCloseExec(int Fd,bool Close); void SetNonBlock(int Fd,bool Block); -- cgit v1.2.3 From d90d3a05de6c550ae2bf54347cda7b39074e63ef Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 18 Feb 2012 18:23:09 +0100 Subject: * apt-pkg/indexrecords.cc: - do not create empty Entries as a sideeffect of Lookup() --- apt-pkg/indexrecords.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/indexrecords.cc b/apt-pkg/indexrecords.cc index cdb9250e8..af2639beb 100644 --- a/apt-pkg/indexrecords.cc +++ b/apt-pkg/indexrecords.cc @@ -44,7 +44,10 @@ time_t indexRecords::GetValidUntil() const const indexRecords::checkSum *indexRecords::Lookup(const string MetaKey) { - return Entries[MetaKey]; + std::map::const_iterator sum = Entries.find(MetaKey); + if (sum == Entries.end()) + return NULL; + return sum->second; } bool indexRecords::Exists(string const &MetaKey) const -- cgit v1.2.3 From c0d58f4276a75f3cd6ebedf20458321a3477a048 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 18 Feb 2012 19:17:57 +0100 Subject: ensure that the cache-directories are really directories before trying to get a list of included files from them --- apt-pkg/cachefile.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index e425c940d..f852542e5 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -182,7 +182,7 @@ void pkgCacheFile::RemoveCaches() { std::string cachedir = flNotFile(pkgcache); std::string cachefile = flNotDir(pkgcache); - if (cachedir.empty() != true && cachefile.empty() != true) + if (cachedir.empty() != true && cachefile.empty() != true && DirectoryExists(cachedir) == true) { cachefile.append("."); std::vector caches = GetListOfFilesInDir(cachedir, false); @@ -201,7 +201,7 @@ void pkgCacheFile::RemoveCaches() std::string cachedir = flNotFile(srcpkgcache); std::string cachefile = flNotDir(srcpkgcache); - if (cachedir.empty() == true || cachefile.empty() == true) + if (cachedir.empty() == true || cachefile.empty() == true || DirectoryExists(cachedir) == false) return; cachefile.append("."); std::vector caches = GetListOfFilesInDir(cachedir, false); -- cgit v1.2.3 From 8e3900d0d7efc11d538b944ed1d9e4e3d5286ff6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 18 Feb 2012 19:40:13 +0100 Subject: * apt-pkg/acquire-item.cc: - drop support for i18n/Index file (introduced in 0.8.11) and use the Release file instead to get the Translations (Closes: #649314) * ftparchive/writer.cc: - add 'Translation-*' to the default patterns i18n/Index was never used outside debian - and even here it isn't used consistently as only 'main' has such a file. As the Release file now includes the Translation-* files we therefore drop support for i18n/Index. A version supporting it was never part of a debian release and still supporting it would mean that we get 99% of the time a 404 as response to the request anyway and confuse archive maintainers who want to provide all files APT tries to acquire. --- apt-pkg/acquire-item.cc | 67 ++++++++++++++------------------------------- apt-pkg/deb/debmetaindex.cc | 36 ++++++++---------------- 2 files changed, 31 insertions(+), 72 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index f231c42b4..ca40b0bd7 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -189,14 +189,14 @@ void pkgAcquire::Item::ReportMirrorFailure(string FailCode) /*}}}*/ // AcqSubIndex::AcqSubIndex - Constructor /*{{{*/ // --------------------------------------------------------------------- -/* Get the Index file first and see if there are languages available - * If so, create a pkgAcqIndexTrans for the found language(s). - */ +/* Get a sub-index file based on checksums from a 'master' file and + possibly query additional files */ pkgAcqSubIndex::pkgAcqSubIndex(pkgAcquire *Owner, string const &URI, string const &URIDesc, string const &ShortDesc, HashString const &ExpectedHash) : Item(Owner), ExpectedHash(ExpectedHash) { + /* XXX: Beware: Currently this class does nothing (of value) anymore ! */ Debug = _config->FindB("Debug::pkgAcquire::SubIndex",false); DestFile = _config->FindDir("Dir::State::lists") + "partial/"; @@ -236,17 +236,7 @@ void pkgAcqSubIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /*{{{* Status = StatDone; Dequeue(); - // No good Index is provided, so try guessing - std::vector langs = APT::Configuration::getLanguages(true); - for (std::vector::const_iterator l = langs.begin(); - l != langs.end(); ++l) - { - if (*l == "none") continue; - string const file = "Translation-" + *l; - new pkgAcqIndexTrans(Owner, Desc.URI.substr(0, Desc.URI.rfind('/')+1).append(file), - Desc.Description.erase(Desc.Description.rfind(' ')+1).append(file), - file); - } + // No good Index is provided } /*}}}*/ void pkgAcqSubIndex::Done(string Message,unsigned long long Size,string Md5Hash, /*{{{*/ @@ -305,38 +295,7 @@ bool pkgAcqSubIndex::ParseIndex(string const &IndexFile) /*{{{*/ indexRecords SubIndexParser; if (FileExists(IndexFile) == false || SubIndexParser.Load(IndexFile) == false) return false; - - std::vector lang = APT::Configuration::getLanguages(true); - for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); ++l) - { - if (*l == "none") - continue; - - string file = "Translation-" + *l; - indexRecords::checkSum const *Record = SubIndexParser.Lookup(file); - HashString expected; - if (Record == NULL) - { - // FIXME: the Index file provided by debian currently only includes bz2 records - Record = SubIndexParser.Lookup(file + ".bz2"); - if (Record == NULL) - continue; - } - else - { - expected = Record->Hash; - if (expected.empty() == true) - continue; - } - - IndexTarget target; - target.Description = Desc.Description.erase(Desc.Description.rfind(' ')+1).append(file); - target.MetaKey = file; - target.ShortDesc = file; - target.URI = Desc.URI.substr(0, Desc.URI.rfind('/')+1).append(file); - new pkgAcqIndexTrans(Owner, &target, expected, &SubIndexParser); - } + // so something with the downloaded index return true; } /*}}}*/ @@ -1385,6 +1344,18 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ return; } #endif + bool transInRelease = false; + { + std::vector const keys = MetaIndexParser->MetaKeys(); + for (std::vector::const_iterator k = keys.begin(); k != keys.end(); ++k) + // FIXME: Feels wrong to check for hardcoded string here, but what should we do else… + if (k->find("Translation-") != std::string::npos) + { + transInRelease = true; + break; + } + } + for (vector ::const_iterator Target = IndexTargets->begin(); Target != IndexTargets->end(); ++Target) @@ -1422,8 +1393,10 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ if ((*Target)->IsSubIndex() == true) new pkgAcqSubIndex(Owner, (*Target)->URI, (*Target)->Description, (*Target)->ShortDesc, ExpectedIndexHash); - else + else if (transInRelease == false || MetaIndexParser->Exists((*Target)->MetaKey) == true) + { new pkgAcqIndexTrans(Owner, *Target, ExpectedIndexHash, MetaIndexParser); + } continue; } diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index 5d3a80aa5..bcc617da7 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -128,7 +128,7 @@ string debReleaseIndex::TranslationIndexURISuffix(const char *Type, const string { string Res =""; if (Dist[Dist.size() - 1] != '/') - Res += Section + "/i18n/"; + Res += Section + "/i18n/Translation-"; return Res + Type; } @@ -210,31 +210,17 @@ vector * debReleaseIndex::ComputeIndexTargets() const { if (lang.empty() == true) return IndexTargets; - // get the Translations: - // - if its a dists-style repository get the i18n/Index first - // - if its flat try to acquire files by guessing - if (Dist[Dist.size() - 1] == '/') { - for (std::set::const_iterator s = sections.begin(); - s != sections.end(); ++s) { - for (std::vector::const_iterator l = lang.begin(); - l != lang.end(); ++l) { - IndexTarget * Target = new OptionalIndexTarget(); - Target->ShortDesc = "Translation-" + *l; - Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s); - Target->URI = TranslationIndexURI(l->c_str(), *s); - Target->Description = Info (Target->ShortDesc.c_str(), *s); - IndexTargets->push_back(Target); - } - } - } else { - for (std::set::const_iterator s = sections.begin(); - s != sections.end(); ++s) { - IndexTarget * Target = new OptionalSubIndexTarget(); - Target->ShortDesc = "TranslationIndex"; - Target->MetaKey = TranslationIndexURISuffix("Index", *s); - Target->URI = TranslationIndexURI("Index", *s); + // get the Translation-* files, later we will skip download of non-existent if we have an index + for (std::set::const_iterator s = sections.begin(); + s != sections.end(); ++s) { + for (std::vector::const_iterator l = lang.begin(); + l != lang.end(); ++l) { + IndexTarget * Target = new OptionalIndexTarget(); + Target->ShortDesc = "Translation-" + *l; + Target->MetaKey = TranslationIndexURISuffix(l->c_str(), *s); + Target->URI = TranslationIndexURI(l->c_str(), *s); Target->Description = Info (Target->ShortDesc.c_str(), *s); - IndexTargets->push_back (Target); + IndexTargets->push_back(Target); } } -- cgit v1.2.3 From f55602cb0cd7403206752479b2ec11c6367e2f6d Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 18 Feb 2012 19:48:04 +0100 Subject: use pdiff for Translation-* files if available (Closes: #657902) Beware: pdiffs for Translation-* are only acquired if their availability is advertised in the Release file. --- apt-pkg/acquire-item.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index ca40b0bd7..4e6fb7ff9 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1395,7 +1395,12 @@ void pkgAcqMetaIndex::QueueIndexes(bool verify) /*{{{*/ (*Target)->ShortDesc, ExpectedIndexHash); else if (transInRelease == false || MetaIndexParser->Exists((*Target)->MetaKey) == true) { - new pkgAcqIndexTrans(Owner, *Target, ExpectedIndexHash, MetaIndexParser); + if (_config->FindB("Acquire::PDiffs",true) == true && transInRelease == true && + MetaIndexParser->Exists(string((*Target)->MetaKey).append(".diff/Index")) == true) + new pkgAcqDiffIndex(Owner, (*Target)->URI, (*Target)->Description, + (*Target)->ShortDesc, ExpectedIndexHash); + else + new pkgAcqIndexTrans(Owner, *Target, ExpectedIndexHash, MetaIndexParser); } continue; } -- cgit v1.2.3 From 6b92f60c38c2d50040bc3f07d52e8da80ef23bff Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 3 Mar 2012 10:02:06 +0100 Subject: eanup the ordering-code avoiding a break (no function change) --- apt-pkg/packagemanager.cc | 51 +++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index a370f15a3..42473341c 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -689,35 +689,30 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c } // Check if it needs to be unpacked - if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && + if (List->IsFlag(BrokenPkg,pkgOrderList::InList) && Cache[BrokenPkg].Delete() == false && List->IsNow(BrokenPkg)) { - if (List->IsFlag(BrokenPkg,pkgOrderList::Loop) && PkgLoop) { - // This dependancy has already been dealt with by another SmartUnPack on Pkg - break; - } else if (List->IsFlag(Pkg,pkgOrderList::Loop)) { - /* Found a break, so unpack the package, but dont remove loop as already set. - This means that there is another SmartUnPack call for this - package and it will remove the loop flag. */ - if (Debug) - cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; - - SmartUnPack(BrokenPkg, false, Depth + 1); - } else { - List->Flag(Pkg,pkgOrderList::Loop); - // Found a break, so unpack the package - if (Debug) - cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid break" << endl; - - SmartUnPack(BrokenPkg, false, Depth + 1); - List->RmFlag(Pkg,pkgOrderList::Loop); - } - } - - // Check if a package needs to be removed - if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) { - if (Debug) - cout << OutputInDepth(Depth) << " Removing " << BrokenPkg.Name() << " to avoid break" << endl; - SmartRemove(BrokenPkg); + if (List->IsFlag(BrokenPkg,pkgOrderList::Loop) && PkgLoop) { + // This dependancy has already been dealt with by another SmartUnPack on Pkg + break; + } else { + // Found a break, so unpack the package, + // but do not set loop if another SmartUnPack already deals with it + if (Debug) + cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid " << End << endl; + if (PkgLoop == false) + List->Flag(Pkg,pkgOrderList::Loop); + SmartUnPack(BrokenPkg, false, Depth + 1); + if (PkgLoop == false) + List->RmFlag(Pkg,pkgOrderList::Loop); + } + } else { + // Check if a package needs to be removed + if (Cache[BrokenPkg].Delete() == true && !List->IsFlag(BrokenPkg,pkgOrderList::Configured)) + { + if (Debug) + cout << OutputInDepth(Depth) << " Removing " << BrokenPkg.Name() << " to avoid " << End << endl; + SmartRemove(BrokenPkg); + } } } } -- cgit v1.2.3 From 2264548ff25c3e7f8b6df22fdd59a95b11ad1462 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 3 Mar 2012 10:08:19 +0100 Subject: show in the debug output if we are looping in the avoid breaks --- apt-pkg/packagemanager.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 42473341c..2738a8a6b 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -698,7 +698,12 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c // Found a break, so unpack the package, // but do not set loop if another SmartUnPack already deals with it if (Debug) - cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid " << End << endl; + { + cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid " << End; + if (PkgLoop == true) + cout << " (Looping)"; + cout << std::endl; + } if (PkgLoop == false) List->Flag(Pkg,pkgOrderList::Loop); SmartUnPack(BrokenPkg, false, Depth + 1); -- cgit v1.2.3 From 440d3d654a5f85e8b5c0472e91f425fbac9541b8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 3 Mar 2012 11:43:21 +0100 Subject: * apt-pkg/packagemanager.cc: - do not try to a void a breaks if the broken package pre-depends on the breaker, but let dpkg auto-deconfigure it --- apt-pkg/packagemanager.cc | 52 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 2738a8a6b..05eb1a06b 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -680,7 +680,6 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c { VerIterator Ver(Cache,*I); PkgIterator BrokenPkg = Ver.ParentPkg(); - VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer); if (BrokenPkg.CurrentVer() != Ver) { if (Debug) @@ -695,20 +694,49 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg, bool const Immediate, int c // This dependancy has already been dealt with by another SmartUnPack on Pkg break; } else { - // Found a break, so unpack the package, + // Found a break, so see if we can unpack the package to avoid it // but do not set loop if another SmartUnPack already deals with it - if (Debug) + VerIterator InstallVer(Cache,Cache[BrokenPkg].InstallVer); + bool circle = false; + for (pkgCache::DepIterator D = InstallVer.DependsList(); D.end() == false; ++D) + { + if (D->Type != pkgCache::Dep::PreDepends) + continue; + SPtrArray VL = D.AllTargets(); + for (Version **I = VL; *I != 0; ++I) + { + VerIterator V(Cache,*I); + PkgIterator P = V.ParentPkg(); + // we are checking for installation as an easy 'protection' against or-groups and (unchosen) providers + if (P->CurrentVer == 0 || P != Pkg || (P.CurrentVer() != V && Cache[P].InstallVer != V)) + continue; + circle = true; + break; + } + if (circle == true) + break; + } + if (circle == true) + { + if (Debug) + cout << OutputInDepth(Depth) << " Avoiding " << End << " avoided as " << BrokenPkg.FullName() << " has a pre-depends on " << Pkg.FullName() << std::endl; + continue; + } + else { - cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.Name() << " to avoid " << End; - if (PkgLoop == true) - cout << " (Looping)"; - cout << std::endl; + if (Debug) + { + cout << OutputInDepth(Depth) << " Unpacking " << BrokenPkg.FullName() << " to avoid " << End; + if (PkgLoop == true) + cout << " (Looping)"; + cout << std::endl; + } + if (PkgLoop == false) + List->Flag(Pkg,pkgOrderList::Loop); + SmartUnPack(BrokenPkg, false, Depth + 1); + if (PkgLoop == false) + List->RmFlag(Pkg,pkgOrderList::Loop); } - if (PkgLoop == false) - List->Flag(Pkg,pkgOrderList::Loop); - SmartUnPack(BrokenPkg, false, Depth + 1); - if (PkgLoop == false) - List->RmFlag(Pkg,pkgOrderList::Loop); } } else { // Check if a package needs to be removed -- cgit v1.2.3 From de498a528cd6fc36c4bb22bf8dec6558e21cc9b6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Mar 2012 22:50:21 +0100 Subject: * apt-pkg/acquire-item.cc: - remove 'old' InRelease file if we can't get a new one before proceeding with Release.gpg to avoid the false impression of a still trusted repository by a (still present) old InRelease file. Thanks to Simon Ruderich for reporting this issue! (CVE-2012-0214) Effected are all versions >= 0.8.11 Possible attack summary: - Attacker needs to find a user which has run at least one successful 'apt-get update' against an archive providing InRelease files. - Create a Packages file with his preferred content. - Attacker then prevents the download of InRelease, Release and Release.gpg (alternatively he creates a valid Release file and sends this, the other two files need to be missing either way). - User updates against this, getting the modified Packages file without any indication of being unsigned (beside the "Ign InRelease" and "Ign Release.gpg" in the output of 'apt-get update'). => deb files from this source are considered 'trusted' (and therefore the user isn't asked for an additional confirmation before install) --- apt-pkg/acquire-item.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 4e6fb7ff9..545a57d37 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1598,6 +1598,13 @@ void pkgAcqMetaClearSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf) /* { if (AuthPass == false) { + // Remove the 'old' InRelease file if we try Release.gpg now as otherwise + // the file will stay around and gives a false-auth impression (CVE-2012-0214) + string FinalFile = _config->FindDir("Dir::State::lists"); + FinalFile.append(URItoFileName(RealURI)); + if (FileExists(FinalFile)) + unlink(FinalFile.c_str()); + new pkgAcqMetaSig(Owner, MetaSigURI, MetaSigURIDesc, MetaSigShortDesc, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc, -- cgit v1.2.3 From b1803e01ec18a4946523f3c3d0cbff2f0347ff30 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Mar 2012 23:01:59 +0100 Subject: handle a SIGINT in all modes as a break after the currently running dpkg transaction instead of ignoring it completely --- apt-pkg/deb/dpkgpm.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 499c3db8a..8aea2e1c8 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -860,6 +860,8 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds, */ bool pkgDPkgPM::Go(int OutStatusFd) { + pkgPackageManager::SigINTStop = false; + // Generate the base argument list for dpkg std::vector Args; unsigned long StartSize = 0; @@ -1429,9 +1431,8 @@ bool pkgDPkgPM::Go(int OutStatusFd) } void SigINT(int sig) { - if (_config->FindB("APT::Immediate-Configure-All",false)) - pkgPackageManager::SigINTStop = true; -} + pkgPackageManager::SigINTStop = true; +} /*}}}*/ // pkgDpkgPM::Reset - Dump the contents of the command list /*{{{*/ // --------------------------------------------------------------------- -- cgit v1.2.3 From dcaa1185506986142bccd990a5dca4c6ec1228cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 4 Mar 2012 23:47:05 +0100 Subject: fix a bunch of cppcheck "(warning) Member variable '<#>' is not initialized in the constructor." messages (no functional change) --- apt-pkg/acquire.cc | 2 +- apt-pkg/algorithms.cc | 2 +- apt-pkg/cachefile.cc | 2 +- apt-pkg/cachefilter.cc | 2 +- apt-pkg/deb/dpkgpm.cc | 4 +++- apt-pkg/orderlist.cc | 14 ++++++-------- apt-pkg/packagemanager.cc | 11 +++++------ apt-pkg/pkgrecords.cc | 2 +- apt-pkg/pkgsystem.cc | 4 ++-- apt-pkg/sourcelist.cc | 2 +- apt-pkg/srcrecords.cc | 2 +- apt-pkg/tagfile.cc | 5 ++++- apt-pkg/version.cc | 4 ++-- 13 files changed, 29 insertions(+), 27 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index cdc3fba4b..573a85c2f 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -766,7 +766,7 @@ void pkgAcquire::Queue::Bump() // AcquireStatus::pkgAcquireStatus - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgAcquireStatus::pkgAcquireStatus() : Update(true), MorePulses(false) +pkgAcquireStatus::pkgAcquireStatus() : d(NULL), Update(true), MorePulses(false) { Start(); } diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index c337ace87..ed3534f0d 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -471,7 +471,7 @@ bool pkgMinimizeUpgrade(pkgDepCache &Cache) // ProblemResolver::pkgProblemResolver - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : Cache(*pCache) +pkgProblemResolver::pkgProblemResolver(pkgDepCache *pCache) : d(NULL), Cache(*pCache) { // Allocate memory unsigned long Size = Cache.Head().PackageCount; diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index f852542e5..7c2276185 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -30,7 +30,7 @@ // CacheFile::CacheFile - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgCacheFile::pkgCacheFile() : Map(NULL), Cache(NULL), DCache(NULL), +pkgCacheFile::pkgCacheFile() : d(NULL), Map(NULL), Cache(NULL), DCache(NULL), SrcList(NULL), Policy(NULL) { } diff --git a/apt-pkg/cachefilter.cc b/apt-pkg/cachefilter.cc index 210a9a9ab..9ec3fa699 100644 --- a/apt-pkg/cachefilter.cc +++ b/apt-pkg/cachefilter.cc @@ -18,7 +18,7 @@ /*}}}*/ namespace APT { namespace CacheFilter { -PackageNameMatchesRegEx::PackageNameMatchesRegEx(std::string const &Pattern) {/*{{{*/ +PackageNameMatchesRegEx::PackageNameMatchesRegEx(std::string const &Pattern) : d(NULL) {/*{{{*/ pattern = new regex_t; int const Res = regcomp(pattern, Pattern.c_str(), REG_EXTENDED | REG_ICASE | REG_NOSUB); if (Res == 0) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 8aea2e1c8..469132634 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -51,8 +51,10 @@ using namespace std; class pkgDPkgPMPrivate { public: - pkgDPkgPMPrivate() : dpkgbuf_pos(0), term_out(NULL), history_out(NULL) + pkgDPkgPMPrivate() : stdin_is_dev_null(false), dpkgbuf_pos(0), + term_out(NULL), history_out(NULL) { + dpkgbuf[0] = '\0'; } bool stdin_is_dev_null; // the buffer we use for the dpkg status-fd reading diff --git a/apt-pkg/orderlist.cc b/apt-pkg/orderlist.cc index 0ac9a83e3..3a179b2a2 100644 --- a/apt-pkg/orderlist.cc +++ b/apt-pkg/orderlist.cc @@ -82,16 +82,14 @@ pkgOrderList *pkgOrderList::Me = 0; // OrderList::pkgOrderList - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgOrderList::pkgOrderList(pkgDepCache *pCache) : Cache(*pCache) +pkgOrderList::pkgOrderList(pkgDepCache *pCache) : Cache(*pCache), + Primary(NULL), Secondary(NULL), + RevDepends(NULL), Remove(NULL), + AfterEnd(NULL), FileList(NULL), + LoopCount(-1), Depth(0) { - FileList = 0; - Primary = 0; - Secondary = 0; - RevDepends = 0; - Remove = 0; - LoopCount = -1; Debug = _config->FindB("Debug::pkgOrderList",false); - + /* Construct the arrays, egcs 1.0.1 bug requires the package count hack */ unsigned long Size = Cache.Head().PackageCount; diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 05eb1a06b..5b5961aca 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -36,11 +36,13 @@ bool pkgPackageManager::SigINTStop = false; // PM::PackageManager - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ -pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache) +pkgPackageManager::pkgPackageManager(pkgDepCache *pCache) : Cache(*pCache), + List(NULL), Res(Incomplete) { FileNames = new string[Cache.Head().PackageCount]; - List = 0; Debug = _config->FindB("Debug::pkgPackageManager",false); + NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); + ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false); } /*}}}*/ // PM::PackageManager - Destructor /*{{{*/ @@ -169,10 +171,7 @@ bool pkgPackageManager::CreateOrderList() delete List; List = new pkgOrderList(&Cache); - - NoImmConfigure = !_config->FindB("APT::Immediate-Configure",true); - ImmConfigureAll = _config->FindB("APT::Immediate-Configure-All",false); - + if (Debug && ImmConfigureAll) clog << "CreateOrderList(): Adding Immediate flag for all packages because of APT::Immediate-Configure-All" << endl; diff --git a/apt-pkg/pkgrecords.cc b/apt-pkg/pkgrecords.cc index c5b3bebd7..36dab3480 100644 --- a/apt-pkg/pkgrecords.cc +++ b/apt-pkg/pkgrecords.cc @@ -22,7 +22,7 @@ // Records::pkgRecords - Constructor /*{{{*/ // --------------------------------------------------------------------- /* This will create the necessary structures to access the status files */ -pkgRecords::pkgRecords(pkgCache &Cache) : Cache(Cache), +pkgRecords::pkgRecords(pkgCache &Cache) : d(NULL), Cache(Cache), Files(Cache.HeaderP->PackageFileCount) { for (pkgCache::PkgFileIterator I = Cache.FileBegin(); diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc index f61c140fa..05ba6e0e6 100644 --- a/apt-pkg/pkgsystem.cc +++ b/apt-pkg/pkgsystem.cc @@ -26,11 +26,11 @@ unsigned long pkgSystem::GlobalListLen = 0; // System::pkgSystem - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Add it to the global list.. */ -pkgSystem::pkgSystem() +pkgSystem::pkgSystem() : Label(NULL), VS(NULL) { assert(GlobalListLen < sizeof(SysList)/sizeof(*SysList)); SysList[GlobalListLen] = this; - GlobalListLen++; + ++GlobalListLen; } /*}}}*/ // System::GetSystem - Get the named system /*{{{*/ diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index f5f458099..0fddfb451 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -33,7 +33,7 @@ unsigned long pkgSourceList::Type::GlobalListLen = 0; // Type::Type - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Link this to the global list of items*/ -pkgSourceList::Type::Type() +pkgSourceList::Type::Type() : Name(NULL), Label(NULL) { ItmList[GlobalListLen] = this; GlobalListLen++; diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 48b643eac..d63d2c422 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -25,7 +25,7 @@ // SrcRecords::pkgSrcRecords - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Open all the source index files */ -pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : Files(0), Current(0) +pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : d(NULL), Files(0), Current(0) { for (pkgSourceList::const_iterator I = List.begin(); I != List.end(); ++I) { diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index ec86173df..79811899a 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -30,7 +30,10 @@ using std::string; class pkgTagFilePrivate { public: - pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Size(Size) + pkgTagFilePrivate(FileFd *pFd, unsigned long long Size) : Fd(*pFd), Buffer(NULL), + Start(NULL), End(NULL), + Done(false), iOffset(0), + Size(Size) { } FileFd &Fd; diff --git a/apt-pkg/version.cc b/apt-pkg/version.cc index a9d4fb763..cb2c34c0f 100644 --- a/apt-pkg/version.cc +++ b/apt-pkg/version.cc @@ -23,10 +23,10 @@ unsigned long pkgVersioningSystem::GlobalListLen = 0; // pkgVS::pkgVersioningSystem - Constructor /*{{{*/ // --------------------------------------------------------------------- /* Link to the global list of versioning systems supported */ -pkgVersioningSystem::pkgVersioningSystem() +pkgVersioningSystem::pkgVersioningSystem() : Label(NULL) { VSList[GlobalListLen] = this; - GlobalListLen++; + ++GlobalListLen; } /*}}}*/ // pkgVS::GetVS - Find a VS by name /*{{{*/ -- cgit v1.2.3 From b3c36c6e2f0c78797d1398e3176aac6a48b36295 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Mar 2012 00:25:32 +0100 Subject: set char-limits for the scanf parsing previous crash-reports --- apt-pkg/deb/dpkgpm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 469132634..c46a81209 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1542,7 +1542,7 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg) if(strstr(strbuf,"Package:") == strbuf) { char pkgname[255], version[255]; - if(sscanf(strbuf, "Package: %s %s", pkgname, version) == 2) + if(sscanf(strbuf, "Package: %254s %254s", pkgname, version) == 2) if(strcmp(pkgver.c_str(), version) == 0) { fclose(report); -- cgit v1.2.3 From 324cbd5693a3cf13224561aa14fc2057d8696469 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 5 Mar 2012 00:37:54 +0100 Subject: as we parse datestrings from external sources a lot specify the length of the integer fields as well to avoid crashes in scanf as cppchecks warns: "(warning) scanf without field width limits can crash with huge input data" --- apt-pkg/contrib/strutl.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 861cdcbeb..99efa8d98 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -910,17 +910,17 @@ bool StrToTime(const string &Val,time_t &Result) // Handle RFC 1123 time Month[0] = 0; - if (sscanf(I," %d %3s %d %d:%d:%d GMT",&Tm.tm_mday,Month,&Tm.tm_year, + if (sscanf(I," %2d %3s %4d %2d:%2d:%2d GMT",&Tm.tm_mday,Month,&Tm.tm_year, &Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec) != 6) { // Handle RFC 1036 time - if (sscanf(I," %d-%3s-%d %d:%d:%d GMT",&Tm.tm_mday,Month, + if (sscanf(I," %2d-%3s-%3d %2d:%2d:%2d GMT",&Tm.tm_mday,Month, &Tm.tm_year,&Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec) == 6) Tm.tm_year += 1900; else { // asctime format - if (sscanf(I," %3s %d %d:%d:%d %d",Month,&Tm.tm_mday, + if (sscanf(I," %3s %2d %2d:%2d:%2d %4d",Month,&Tm.tm_mday, &Tm.tm_hour,&Tm.tm_min,&Tm.tm_sec,&Tm.tm_year) != 6) { // 'ftp' time -- cgit v1.2.3 From 84e254d6aee034fec6ca10c4e5765d1280d0de0e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 6 Mar 2012 10:53:35 +0100 Subject: * apt-pkg/contrib/fileutl.cc: - do not warn about the ignoring of directories (Closes: #662762) --- apt-pkg/contrib/fileutl.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 557ba0ca6..1808489d7 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -387,6 +387,13 @@ std::vector GetListOfFilesInDir(string const &Dir, std::vector c { if (RealFileExists(File.c_str()) == false) { + // do not show ignoration warnings for directories + if ( +#ifdef _DIRENT_HAVE_D_TYPE + Ent->d_type == DT_DIR || +#endif + DirectoryExists(File.c_str()) == true) + continue; if (SilentIgnore.Match(Ent->d_name) == false) _error->Notice(_("Ignoring '%s' in directory '%s' as it is not a regular file"), Ent->d_name, Dir.c_str()); continue; -- cgit v1.2.3 From de31189fca11b7de937a64de90bcc050b76f9181 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 6 Mar 2012 17:58:16 +0100 Subject: add Debug::pkgAcqArchive::NoQueue to disable package downloading --- apt-pkg/acquire-item.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc index 545a57d37..a30e98858 100644 --- a/apt-pkg/acquire-item.cc +++ b/apt-pkg/acquire-item.cc @@ -1810,7 +1810,18 @@ bool pkgAcqArchive::QueueNext() else PartialSize = Buf.st_size; } - + + // Disables download of archives - useful if no real installation follows, + // e.g. if we are just interested in proposed installation order + if (_config->FindB("Debug::pkgAcqArchive::NoQueue", false) == true) + { + Complete = true; + Local = true; + Status = StatDone; + StoreFilename = DestFile = FinalFile; + return true; + } + // Create the item Local = false; Desc.URI = Index->ArchiveURI(PkgFile); -- cgit v1.2.3