summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/deblistparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb/deblistparser.cc')
-rw-r--r--apt-pkg/deb/deblistparser.cc35
1 files changed, 26 insertions, 9 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 6b8fbce99..a4a974897 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -200,7 +200,7 @@ string debListParser::DescriptionLanguage()
std::vector<string> const lang = APT::Configuration::getLanguages(true);
for (std::vector<string>::const_iterator l = lang.begin();
- l != lang.end(); l++)
+ l != lang.end(); ++l)
if (Section.FindS(string("Description-").append(*l).c_str()).empty() == false)
return *l;
@@ -458,7 +458,7 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
*
* The complete architecture, consisting of <kernel>-<cpu>.
*/
-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";
@@ -497,9 +497,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);
}
@@ -540,7 +544,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
@@ -778,7 +781,9 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
size_t len = 0;
// Skip empty lines
- for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len);
+ for (; buffer[len] == '\r' && buffer[len] == '\n'; ++len)
+ /* nothing */
+ ;
if (buffer[len] == '\0')
continue;
@@ -792,13 +797,25 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
}
// seperate the tag from the data
- for (; buffer[len] != ':' && buffer[len] != '\0'; ++len);
+ for (; buffer[len] != ':' && buffer[len] != '\0'; ++len)
+ /* nothing */
+ ;
if (buffer[len] == '\0')
continue;
char* dataStart = buffer + len;
- for (++dataStart; *dataStart == ' '; ++dataStart);
+ for (++dataStart; *dataStart == ' '; ++dataStart)
+ /* nothing */
+ ;
char* dataEnd = dataStart;
- for (++dataEnd; *dataEnd != '\0'; ++dataEnd);
+ for (++dataEnd; *dataEnd != '\0'; ++dataEnd)
+ /* nothing */
+ ;
+ // The last char should be a newline, but we can never be sure: #633350
+ char* lineEnd = dataEnd;
+ for (--lineEnd; *lineEnd == '\r' || *lineEnd == '\n'; --lineEnd)
+ /* nothing */
+ ;
+ ++lineEnd;
// which datastorage need to be updated
map_ptrloc* writeTo = NULL;
@@ -813,7 +830,7 @@ bool debListParser::LoadReleaseInfo(pkgCache::PkgFileIterator &FileI,
APT_PARSER_WRITETO(FileI->Label, "Label")
#undef APT_PARSER_WRITETO
#define APT_PARSER_FLAGIT(X) else if (strncmp(#X, buffer, len) == 0) \
- pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, dataEnd-1);
+ pkgTagSection::FindFlag(FileI->Flags, pkgCache::Flag:: X, dataStart, lineEnd);
APT_PARSER_FLAGIT(NotAutomatic)
APT_PARSER_FLAGIT(ButAutomaticUpgrades)
#undef APT_PARSER_FLAGIT