From 0df8c3dccbda739af6e20999fb208ada0619ad80 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 15 Jul 2011 10:39:58 +0200 Subject: apt-pkg/contrib/configuration.cc: revert Configuration::Set() ABI break --- apt-pkg/contrib/configuration.cc | 2 +- apt-pkg/contrib/configuration.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 0664e3704..942ea9fbc 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -345,7 +345,7 @@ void Configuration::Set(const char *Name,const string &Value) // Configuration::Set - Set an integer value /*{{{*/ // --------------------------------------------------------------------- /* */ -void Configuration::Set(const char *Name,int const Value) +void Configuration::Set(const char *Name,int const &Value) { Item *Itm = Lookup(Name,true); if (Itm == 0) diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h index 3568ce815..2844ec097 100644 --- a/apt-pkg/contrib/configuration.h +++ b/apt-pkg/contrib/configuration.h @@ -84,7 +84,7 @@ class Configuration void CndSet(const char *Name,const string &Value); void CndSet(const char *Name,const int Value); void Set(const char *Name,const string &Value); - void Set(const char *Name,const int Value); + void Set(const char *Name,const int &Value); inline bool Exists(const string &Name) const {return Exists(Name.c_str());}; bool Exists(const char *Name) const; -- cgit v1.2.3 From 4a53151acad0c4ccfbcf4ce11c5c2d7cffd05de3 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 16 Jul 2011 14:57:37 +0200 Subject: do not require unused partial dirs in 'source' (Closes: #633510) --- apt-pkg/acquire.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index e3a4435b8..9fe0e8a87 100644 --- a/apt-pkg/acquire.h +++ b/apt-pkg/acquire.h @@ -348,6 +348,8 @@ class pkgAcquire */ bool Setup(pkgAcquireStatus *Progress = NULL, string const &Lock = ""); + void SetLog(pkgAcquireStatus *Progress) { Log = Progress; } + /** \brief Construct a new pkgAcquire. */ pkgAcquire(pkgAcquireStatus *Log) __deprecated; pkgAcquire(); -- cgit v1.2.3 From a3bbbab7ca5f94391b2158cfe9deb85eb335e29a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 16 Jul 2011 16:48:03 +0200 Subject: * apt-pkg/policy.cc: - emit an error on unknown APT::Default-Release value (Closes: #407511) --- apt-pkg/policy.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc index bd213e0ce..c5028d822 100644 --- a/apt-pkg/policy.cc +++ b/apt-pkg/policy.cc @@ -56,8 +56,22 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(0), PFPriority(0), Cache(Owner) // The config file has a master override. string DefRel = _config->Find("APT::Default-Release"); if (DefRel.empty() == false) - CreatePin(pkgVersionMatch::Release,"",DefRel,990); - + { + bool found = false; + // FIXME: make ExpressionMatches static to use it here easily + pkgVersionMatch vm("", pkgVersionMatch::None); + for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F != Cache->FileEnd(); ++F) + { + if ((F->Archive != 0 && vm.ExpressionMatches(DefRel, F.Archive()) == true) || + (F->Codename != 0 && vm.ExpressionMatches(DefRel, F.Codename()) == true) || + (F->Version != 0 && vm.ExpressionMatches(DefRel, F.Version()) == true)) + found = true; + } + if (found == false) + _error->Error(_("The value '%s' is invalid for APT::Default-Release as such a release is not available in the sources"), DefRel.c_str()); + else + CreatePin(pkgVersionMatch::Release,"",DefRel,990); + } InitDefaults(); } /*}}}*/ -- cgit v1.2.3 From bd9d81e3d793b9fb5c94fd5ad0b00245205b8cbc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Jul 2011 12:37:06 +0200 Subject: * apt-pkg/aptconfiguration.cc: - ensure that native architecture is if not specified otherwise the first architecture in the Architectures vector --- apt-pkg/aptconfiguration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index e8c8e73d0..9ccbeecf1 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -352,7 +352,7 @@ std::vector const Configuration::getArchitectures(bool const &Cache if (archs.empty() == true || std::find(archs.begin(), archs.end(), arch) == archs.end()) - archs.push_back(arch); + archs.insert(archs.begin(), arch); // erase duplicates and empty strings for (std::vector::reverse_iterator a = archs.rbegin(); -- cgit v1.2.3 From 550f6493654e921a8af860694efdb268c9b2a47c Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 25 Jul 2011 12:52:50 +0200 Subject: * apt-pkg/deb/deblistparser.cc: - Strip only :any and :native if MultiArch should be stripped as it is save to ignore them in non-MultiArch contexts but if the dependency is a specific architecture (and not the native) do not strip --- apt-pkg/deb/deblistparser.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 9ae1065a4..651fa2a81 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -461,7 +461,7 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op) * * The complete architecture, consisting of -. */ -static string CompleteArch(std::string& arch) { +static string CompleteArch(std::string const &arch) { if (arch == "armel") return "linux-arm"; if (arch == "armhf") return "linux-arm"; if (arch == "lpia") return "linux-i386"; @@ -500,9 +500,13 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, Package.assign(Start,I - Start); // We don't want to confuse library users which can't handle MultiArch + string const arch = _config->Find("APT::Architecture"); if (StripMultiArch == true) { size_t const found = Package.rfind(':'); - if (found != string::npos) + if (found != string::npos && + (strcmp(Package.c_str() + found, ":any") == 0 || + strcmp(Package.c_str() + found, ":native") == 0 || + strcmp(Package.c_str() + found + 1, arch.c_str()) == 0)) Package = Package.substr(0,found); } @@ -543,7 +547,6 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop, if (ParseArchFlags == true) { - string arch = _config->Find("APT::Architecture"); string completeArch = CompleteArch(arch); // Parse an architecture -- cgit v1.2.3 From f748b4760d0f8247001c0b46e9eaf02b379bc3c4 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 25 Jul 2011 16:53:18 +0200 Subject: * apt-pkg/contrib/cdromutl.cc: - fix escape problem when looking for the mounted devices --- apt-pkg/contrib/cdromutl.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 821e6d688..551efa7d9 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -258,7 +258,13 @@ string FindMountPointForDevice(const char *devnode) if(TokSplitString(' ', buf, out, 10)) { fclose(f); - return string(out[1]); + // unescape \040 and return the path + size_t pos; + string mount_point = out[1]; + static const char *needle = "\\040"; + while ((pos = mount_point.find(needle)) != string::npos) + mount_point.replace(pos, strlen(needle), " "); + return mount_point; } } } -- cgit v1.2.3 From 1edc38abff0bffd56ad7a128f6243050d4064827 Mon Sep 17 00:00:00 2001 From: David Miller Date: Tue, 26 Jul 2011 09:00:10 +0200 Subject: * apt-pkg/contrib/sha1.cc: - fix illegally casts of on-stack buffer to a type requiring more alignment than it has resulting in segfaults on sparc (Closes: #634696) The problem is how sha1.cc codes the SHA1 transform, it illegally casts the on-stack workspace buffer to a type requiring more alignment than 'workspace' is actually declared to have. This only shows up recently because gcc-4.6 now does a really aggressive optimization where it gets rid of the workspace buffer entirely and just accesses 'buffer' directly, and assumes it has the necessary alignment for 32-bit loads (which it doesn't). --- apt-pkg/contrib/sha1.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc index eae52d52f..abc2aaf9f 100644 --- a/apt-pkg/contrib/sha1.cc +++ b/apt-pkg/contrib/sha1.cc @@ -74,10 +74,9 @@ static void SHA1Transform(uint32_t state[5],uint8_t const buffer[64]) uint32_t l[16]; } CHAR64LONG16; - CHAR64LONG16 *block; + CHAR64LONG16 workspace, *block; - uint8_t workspace[64]; - block = (CHAR64LONG16 *)workspace; + block = &workspace; memcpy(block,buffer,sizeof(workspace)); /* Copy context->state[] to working vars */ -- cgit v1.2.3 From a513ace2d2e3b71d607257990893199c6105b072 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 10:49:28 +0200 Subject: * apt-pkg/contrib/strutl.{h,cc}, test/libapt/strutil_test.cc: - add new DeEscapeString() similar to DeQuoteQuotedWord but unescape charackter escapes like \0XXX and \xXX (plus add test) --- apt-pkg/contrib/cdromutl.cc | 8 ++---- apt-pkg/contrib/strutl.cc | 63 +++++++++++++++++++++++++++++++++++++++++++++ apt-pkg/contrib/strutl.h | 4 +++ 3 files changed, 69 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc index 551efa7d9..e25caf1a5 100644 --- a/apt-pkg/contrib/cdromutl.cc +++ b/apt-pkg/contrib/cdromutl.cc @@ -258,13 +258,9 @@ string FindMountPointForDevice(const char *devnode) if(TokSplitString(' ', buf, out, 10)) { fclose(f); - // unescape \040 and return the path - size_t pos; + // unescape the \0XXX chars in the path string mount_point = out[1]; - static const char *needle = "\\040"; - while ((pos = mount_point.find(needle)) != string::npos) - mount_point.replace(pos, strlen(needle), " "); - return mount_point; + return DeEscapeString(mount_point); } } } diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 072dda3ac..a97dd30e5 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1240,7 +1240,70 @@ bool CheckDomainList(const string &Host,const string &List) return false; } /*}}}*/ +// ProcessEscapeSequences /*{{{*/ +// --------------------------------------------------------------------- +/* */ +string DeEscapeString(string &input) +{ + char tmp[5]; + string::const_iterator it, escape_start; + string output, octal, hex; + for (it = input.begin(); it != input.end(); it++) + { + // just copy non-escape chars + if (*it != '\\') + { + output += *it; + continue; + } + + // deal with double escape + if (*it == '\\' && + (it + 1 < input.end()) && it[1] == '\\') + { + // copy + output += *it; + // advance iterator one step further + it += 1; + continue; + } + + // ensure we have a char to read + if (it + 1 == input.end()) + continue; + // read it + it++; + switch (*it) + { + case '0': + if (it + 3 <= input.end()) { + tmp[0] = it[1]; + tmp[1] = it[2]; + tmp[2] = it[3]; + tmp[3] = 0; + output += (char)strtol(tmp, 0, 8); + it += 2; + } + break; + case 'x': + if (it + 2 <= input.end()) { + tmp[0] = it[1]; + tmp[1] = it[2]; + tmp[2] = 0; + output += (char)strtol(tmp, 0, 16); + it += 2; + } + break; + default: + // FIXME: raise exception here? + std::cerr << "lala" << *it << endl; + break; + } + } + return output; +} + /*}}}*/ // URI::CopyFrom - Copy from an object /*{{{*/ // --------------------------------------------------------------------- /* This parses the URI into all of its components */ diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 89cbf0370..43bbfe366 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -39,6 +39,10 @@ bool ParseCWord(const char *&String,string &Res); string QuoteString(const string &Str,const char *Bad); string DeQuoteString(const string &Str); string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end); + +// unescape (\0XXX and \xXX) from a string +string DeEscapeString(string &input); + string SizeToStr(double Bytes); string TimeToStr(unsigned long Sec); string Base64Encode(const string &Str); -- cgit v1.2.3 From e0146bb1813743e9042c2aad4d1131ca382861c1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 10:50:43 +0200 Subject: apt-pkg/contrib/strutl.cc: kill unneeded debug output --- apt-pkg/contrib/strutl.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index a97dd30e5..f9d8d7e90 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1297,7 +1297,6 @@ string DeEscapeString(string &input) break; default: // FIXME: raise exception here? - std::cerr << "lala" << *it << endl; break; } } -- cgit v1.2.3 From b9dc47069ab90a79ca3b9eae3cc85d38062d57ee Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 11:10:47 +0200 Subject: add another escape test case, fixup octal one (its \0XX instead of \0XXX) --- apt-pkg/contrib/strutl.cc | 9 ++++----- apt-pkg/contrib/strutl.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index f9d8d7e90..e998d74dc 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1242,10 +1242,10 @@ bool CheckDomainList(const string &Host,const string &List) /*}}}*/ // ProcessEscapeSequences /*{{{*/ // --------------------------------------------------------------------- -/* */ +/* unescape (\0XX and \xXX) from a string */ string DeEscapeString(string &input) { - char tmp[5]; + char tmp[3]; string::const_iterator it, escape_start; string output, octal, hex; for (it = input.begin(); it != input.end(); it++) @@ -1277,11 +1277,10 @@ string DeEscapeString(string &input) switch (*it) { case '0': - if (it + 3 <= input.end()) { + if (it + 2 <= input.end()) { tmp[0] = it[1]; tmp[1] = it[2]; - tmp[2] = it[3]; - tmp[3] = 0; + tmp[2] = 0; output += (char)strtol(tmp, 0, 8); it += 2; } diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 43bbfe366..2a6bc1990 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -40,7 +40,7 @@ string QuoteString(const string &Str,const char *Bad); string DeQuoteString(const string &Str); string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end); -// unescape (\0XXX and \xXX) from a string +// unescape (\0XX and \xXX) from a string string DeEscapeString(string &input); string SizeToStr(double Bytes); -- cgit v1.2.3 From cca2efe60edfae106380a55ee4fb561aa570f2c9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 26 Jul 2011 11:52:42 +0200 Subject: fix typos in changelog, make DeEscapeString const, improve description --- apt-pkg/contrib/strutl.cc | 6 +++--- apt-pkg/contrib/strutl.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index e998d74dc..ab2da2d9a 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1240,10 +1240,10 @@ bool CheckDomainList(const string &Host,const string &List) return false; } /*}}}*/ -// ProcessEscapeSequences /*{{{*/ +// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/ // --------------------------------------------------------------------- -/* unescape (\0XX and \xXX) from a string */ -string DeEscapeString(string &input) +/* */ +string DeEscapeString(const string &input) { char tmp[3]; string::const_iterator it, escape_start; diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 2a6bc1990..fba85cf94 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -41,7 +41,7 @@ string DeQuoteString(const string &Str); string DeQuoteString(string::const_iterator const &begin, string::const_iterator const &end); // unescape (\0XX and \xXX) from a string -string DeEscapeString(string &input); +string DeEscapeString(const string &input); string SizeToStr(double Bytes); string TimeToStr(unsigned long Sec); -- cgit v1.2.3