summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-10-14 09:57:34 +0200
committerMichael Vogt <mvo@debian.org>2014-10-14 09:57:34 +0200
commita4221092e50af0b74040f5b4ee800c78b05fd84e (patch)
tree97e0afa79d72b8ea2206fdac1139d860c49d155a
parent8556d56aabc7162032a55370373d1b8f5af33645 (diff)
parent9227645d6d355f9f4332f400b8d58c8fa8f1e899 (diff)
Merge branch 'debian/sid' into debian/experimental
-rw-r--r--apt-pkg/deb/deblistparser.cc130
-rw-r--r--debian/changelog2
-rw-r--r--doc/dpkg-tech.dbk28
-rw-r--r--methods/rsh.cc13
-rwxr-xr-xtest/integration/test-bug-661537-build-profiles-support86
-rw-r--r--test/libapt/parsedepends_test.cc29
6 files changed, 150 insertions, 138 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 502bd1a51..616d8296d 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -372,13 +372,9 @@ unsigned short debListParser::VersionHash()
/* Status lines are of the form,
Status: want flag status
want = unknown, install, hold, deinstall, purge
- flag = ok, reinstreq, hold, hold-reinstreq
- status = not-installed, unpacked, half-configured,
- half-installed, config-files, post-inst-failed,
- removal-failed, installed
-
- Some of the above are obsolete (I think?) flag = hold-* and
- status = post-inst-failed, removal-failed at least.
+ flag = ok, reinstreq
+ status = not-installed, config-files, half-installed, unpacked,
+ half-configured, triggers-awaited, triggers-pending, installed
*/
bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver)
@@ -435,15 +431,13 @@ bool debListParser::ParseStatus(pkgCache::PkgIterator &Pkg,
// Process the flag field
WordList StatusList[] = {{"not-installed",pkgCache::State::NotInstalled},
+ {"config-files",pkgCache::State::ConfigFiles},
+ {"half-installed",pkgCache::State::HalfInstalled},
{"unpacked",pkgCache::State::UnPacked},
{"half-configured",pkgCache::State::HalfConfigured},
- {"installed",pkgCache::State::Installed},
- {"half-installed",pkgCache::State::HalfInstalled},
- {"config-files",pkgCache::State::ConfigFiles},
{"triggers-awaited",pkgCache::State::TriggersAwaited},
{"triggers-pending",pkgCache::State::TriggersPending},
- {"post-inst-failed",pkgCache::State::HalfConfigured},
- {"removal-failed",pkgCache::State::HalfInstalled},
+ {"installed",pkgCache::State::Installed},
{NULL, 0}};
if (GrabWord(string(Start,I-Start),StatusList,Pkg->CurrentState) == false)
return _error->Error("Malformed 3rd word in the Status line");
@@ -669,72 +663,94 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
if (ParseRestrictionsList == true)
{
- // Parse a restrictions list
- if (I != Stop && *I == '<')
+ // Parse a restrictions formula which is in disjunctive normal form:
+ // (foo AND bar) OR (blub AND bla)
+
+ std::vector<string> const profiles = APT::Configuration::getBuildProfiles();
+
+ // if the next character is a restriction list, then by default the
+ // dependency does not apply and the conditions have to be checked
+ // if the next character is not a restriction list, then by default the
+ // dependency applies
+ bool applies1 = (*I != '<');
+ while (I != Stop)
{
+ if (*I != '<')
+ break;
+
++I;
// malformed
if (unlikely(I == Stop))
return 0;
- std::vector<string> const profiles = APT::Configuration::getBuildProfiles();
-
const char *End = I;
- bool Found = false;
- bool NegRestriction = false;
- while (I != Stop)
- {
- // look for whitespace or ending '>'
- for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
-
- if (unlikely(End == Stop))
- return 0;
- if (*I == '!')
+ // if of the prior restriction list is already fulfilled, then
+ // we can just skip to the end of the current list
+ if (applies1) {
+ for (;End != Stop && *End != '>'; ++End);
+ I = ++End;
+ // skip whitespace
+ for (;I != Stop && isspace(*I) != 0; I++);
+ } else {
+ bool applies2 = true;
+ // all the conditions inside a restriction list have to be
+ // met so once we find one that is not met, we can skip to
+ // the end of this list
+ while (I != Stop)
{
- NegRestriction = true;
- ++I;
- }
+ // look for whitespace or ending '>'
+ // End now points to the character after the current term
+ for (;End != Stop && !isspace(*End) && *End != '>'; ++End);
- std::string restriction(I, End);
+ if (unlikely(End == Stop))
+ return 0;
- std::string prefix = "profile.";
- // only support for "profile" prefix, ignore others
- if (restriction.size() > prefix.size() &&
- restriction.substr(0, prefix.size()) == prefix)
- {
- // get the name of the profile
- restriction = restriction.substr(prefix.size());
+ bool NegRestriction = false;
+ if (*I == '!')
+ {
+ NegRestriction = true;
+ ++I;
+ }
+
+ std::string restriction(I, End);
if (restriction.empty() == false && profiles.empty() == false &&
- std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
+ std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
{
- Found = true;
- if (I[-1] != '!')
- NegRestriction = false;
- // we found a match, so fast-forward to the end of the wildcards
- for (; End != Stop && *End != '>'; ++End);
+ if (NegRestriction) {
+ applies2 = false;
+ // since one of the terms does not apply we don't have to check the others
+ for (; End != Stop && *End != '>'; ++End);
+ }
+ } else {
+ if (!NegRestriction) {
+ applies2 = false;
+ // since one of the terms does not apply we don't have to check the others
+ for (; End != Stop && *End != '>'; ++End);
+ }
+ }
+
+ if (*End++ == '>') {
+ I = End;
+ // skip whitespace
+ for (;I != Stop && isspace(*I) != 0; I++);
+ break;
}
- }
- if (*End++ == '>') {
I = End;
- break;
+ // skip whitespace
+ for (;I != Stop && isspace(*I) != 0; I++);
+ }
+ if (applies2) {
+ applies1 = true;
}
-
- I = End;
- for (;I != Stop && isspace(*I) != 0; I++);
}
-
- if (NegRestriction == true)
- Found = !Found;
-
- if (Found == false)
- Package = ""; /* not for this restriction */
}
- // Skip whitespace
- for (;I != Stop && isspace(*I) != 0; I++);
+ if (applies1 == false) {
+ Package = ""; //not for this restriction
+ }
}
if (I != Stop && *I == '|')
diff --git a/debian/changelog b/debian/changelog
index 2cbfec869..c268f9bb9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -211,7 +211,7 @@ apt (1.0.9.2) unstable; urgency=medium
[ Guillem Jover ]
* apt-get: Create the temporary downloaded changelog inside tmpdir
- (closes: #763780)
+ (closes: #763780) (CVE-2014-7206)
-- Michael Vogt <mvo@debian.org> Thu, 02 Oct 2014 22:05:39 +0200
diff --git a/doc/dpkg-tech.dbk b/doc/dpkg-tech.dbk
index 660ccabc9..2584cf640 100644
--- a/doc/dpkg-tech.dbk
+++ b/doc/dpkg-tech.dbk
@@ -222,13 +222,11 @@ Where <replaceable>Want</replaceable> may be one of
<emphasis>unknown</emphasis>, <emphasis>install</emphasis>,
<emphasis>hold</emphasis>, <emphasis>deinstall</emphasis>,
<emphasis>purge</emphasis>. <replaceable>Flag</replaceable> may
-be one of <emphasis>ok</emphasis>, <emphasis>reinstreq</emphasis>,
-<emphasis>hold</emphasis>,
-<emphasis>hold-reinstreq</emphasis>. <replaceable>Status</replaceable> may
-be one of <emphasis>not-installed</emphasis>, <emphasis>unpacked</emphasis>,
-<emphasis>half-configured</emphasis>, <emphasis>installed</emphasis>,
-<emphasis>half-installed</emphasis> <emphasis>config-files</emphasis>,
-<emphasis>post-inst-failed</emphasis>, <emphasis>removal-failed</emphasis>.
+be one of <emphasis>ok</emphasis>, <emphasis>reinstreq</emphasis>.
+<replaceable>Status</replaceable> may
+be one of <emphasis>not-installed</emphasis>, <emphasis>config-files</emphasis>,
+<emphasis>half-installed</emphasis>, <emphasis>unpacked</emphasis>,
+<emphasis>half-configured</emphasis> and <emphasis>installed</emphasis>.
The states are as follows:-
</para>
<variablelist>
@@ -287,22 +285,6 @@ nothing else.
</para>
</listitem>
</varlistentry>
-<varlistentry>
-<term>post-inst-failed</term>
-<listitem>
-<para>
-Old name for half-configured. Do not use.
-</para>
-</listitem>
-</varlistentry>
-<varlistentry>
-<term>removal-failed</term>
-<listitem>
-<para>
-Old name for half-installed. Do not use.
-</para>
-</listitem>
-</varlistentry>
</variablelist>
<para>
The two last items are only left in dpkg for compatibility - they are
diff --git a/methods/rsh.cc b/methods/rsh.cc
index bd46d2515..0e949160b 100644
--- a/methods/rsh.cc
+++ b/methods/rsh.cc
@@ -218,17 +218,20 @@ bool RSHConn::WriteMsg(std::string &Text,bool Sync,const char *Fmt,...)
va_list args;
va_start(args,Fmt);
- // sprintf the description
- char S[512];
- vsnprintf(S,sizeof(S) - 4,Fmt,args);
+ // sprintf into a buffer
+ char Tmp[1024];
+ vsnprintf(Tmp,sizeof(Tmp),Fmt,args);
va_end(args);
+ // concat to create the real msg
+ std::string Msg;
if (Sync == true)
- strcat(S," 2> /dev/null || echo\n");
+ Msg = std::string(Tmp) + " 2> /dev/null || echo\n";
else
- strcat(S," 2> /dev/null\n");
+ Msg = std::string(Tmp) + " 2> /dev/null\n";
// Send it off
+ const char *S = Msg.c_str();
unsigned long Len = strlen(S);
unsigned long Start = 0;
while (Len != 0)
diff --git a/test/integration/test-bug-661537-build-profiles-support b/test/integration/test-bug-661537-build-profiles-support
index ae1403f71..6c850fdf9 100755
--- a/test/integration/test-bug-661537-build-profiles-support
+++ b/test/integration/test-bug-661537-build-profiles-support
@@ -11,18 +11,16 @@ insertinstalledpackage 'build-essential' 'all' '0' 'Multi-Arch: foreign'
insertpackage 'unstable' 'foo' 'all' '1.0'
insertpackage 'unstable' 'bar' 'all' '1.0'
-insertsource 'unstable' 'buildprofiles' 'any' '1' 'Build-Depends: foo (>= 1.0) [i386 arm] <!profile.stage1 !profile.cross>, bar'
+insertsource 'unstable' 'buildprofiles' 'any' '1' 'Build-Depends: foo (>= 1.0) [i386 arm] <!stage1 !cross>, bar'
# table from https://wiki.debian.org/BuildProfileSpec
-insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo <!profile.stage1>'
-insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo <profile.stage1>'
-insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo <!profile.stage1 !profile.notest>'
-insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo <profile.stage1 profile.notest>'
-insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo <!profile.stage1 profile.notest>'
-insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo <profile.stage1 !profile.notest>'
-# multiple stanzas not supported: error out
-insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo <profile.stage1><!profile.notest>'
-insertsource 'unstable' 'spec-8' 'any' '1' 'Build-Depends: foo <profile.stage1> <!profile.notest>'
+insertsource 'unstable' 'spec-1' 'any' '1' 'Build-Depends: foo <!stage1>'
+insertsource 'unstable' 'spec-2' 'any' '1' 'Build-Depends: foo <stage1>'
+insertsource 'unstable' 'spec-3' 'any' '1' 'Build-Depends: foo <!stage1 !notest>'
+insertsource 'unstable' 'spec-4' 'any' '1' 'Build-Depends: foo <stage1 notest>'
+insertsource 'unstable' 'spec-5' 'any' '1' 'Build-Depends: foo <!stage1 notest>'
+insertsource 'unstable' 'spec-6' 'any' '1' 'Build-Depends: foo <stage1 !notest>'
+insertsource 'unstable' 'spec-7' 'any' '1' 'Build-Depends: foo <stage1> <!notest>'
setupaptarchive
@@ -72,7 +70,7 @@ Building dependency tree...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.'
msgtest 'Check if version of installed dpkg is high enough for' 'build profiles support'
-if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.2'; then
+if dpkg --compare-versions "$(command dpkg-query --showformat='${Version}' --show dpkg)" 'ge' '1.17.14'; then
msgpass
testwithdpkg() {
msgtest "Test with" "dpkg-checkbuilddeps -d '$1' -P '$2'"
@@ -113,35 +111,37 @@ testprofile() {
testwithdpkg "$2" "$3" "$4"
}
-testprofile 'spec-1' 'foo <!profile.stage1>' '' "$KEEP"
-testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1' "$DROP"
-testprofile 'spec-1' 'foo <!profile.stage1>' 'notest' "$KEEP"
-testprofile 'spec-1' 'foo <!profile.stage1>' 'stage1,notest' "$DROP"
-
-testprofile 'spec-2' 'foo <profile.stage1>' '' "$DROP"
-testprofile 'spec-2' 'foo <profile.stage1>' 'stage1' "$KEEP"
-testprofile 'spec-2' 'foo <profile.stage1>' 'notest' "$DROP"
-testprofile 'spec-2' 'foo <profile.stage1>' 'stage1,notest' "$KEEP"
-
-testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' '' "$KEEP"
-testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1' "$DROP"
-testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'notest' "$DROP"
-testprofile 'spec-3' 'foo <!profile.stage1 !profile.notest>' 'stage1,notest' "$DROP"
-
-testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' '' "$DROP"
-testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1' "$KEEP"
-testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'notest' "$KEEP"
-testprofile 'spec-4' 'foo <profile.stage1 profile.notest>' 'stage1,notest' "$KEEP"
-
-testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' '' "$KEEP"
-testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1' "$DROP"
-testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'notest' "$KEEP"
-testprofile 'spec-5' 'foo <!profile.stage1 profile.notest>' 'stage1,notest' "$DROP"
-
-testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' '' "$KEEP"
-testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1' "$KEEP"
-testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'notest' "$DROP"
-testprofile 'spec-6' 'foo <profile.stage1 !profile.notest>' 'stage1,notest' "$KEEP"
-
-testfailure aptget build-dep spec-7 -s
-testfailure aptget build-dep spec-8 -s
+testprofile 'spec-1' 'foo <!stage1>' '' "$KEEP"
+testprofile 'spec-1' 'foo <!stage1>' 'stage1' "$DROP"
+testprofile 'spec-1' 'foo <!stage1>' 'notest' "$KEEP"
+testprofile 'spec-1' 'foo <!stage1>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-2' 'foo <stage1>' '' "$DROP"
+testprofile 'spec-2' 'foo <stage1>' 'stage1' "$KEEP"
+testprofile 'spec-2' 'foo <stage1>' 'notest' "$DROP"
+testprofile 'spec-2' 'foo <stage1>' 'stage1,notest' "$KEEP"
+
+testprofile 'spec-3' 'foo <!stage1 !notest>' '' "$KEEP"
+testprofile 'spec-3' 'foo <!stage1 !notest>' 'stage1' "$DROP"
+testprofile 'spec-3' 'foo <!stage1 !notest>' 'notest' "$DROP"
+testprofile 'spec-3' 'foo <!stage1 !notest>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-4' 'foo <stage1 notest>' '' "$DROP"
+testprofile 'spec-4' 'foo <stage1 notest>' 'stage1' "$DROP"
+testprofile 'spec-4' 'foo <stage1 notest>' 'notest' "$DROP"
+testprofile 'spec-4' 'foo <stage1 notest>' 'stage1,notest' "$KEEP"
+
+testprofile 'spec-5' 'foo <!stage1 notest>' '' "$DROP"
+testprofile 'spec-5' 'foo <!stage1 notest>' 'stage1' "$DROP"
+testprofile 'spec-5' 'foo <!stage1 notest>' 'notest' "$KEEP"
+testprofile 'spec-5' 'foo <!stage1 notest>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-6' 'foo <stage1 !notest>' '' "$DROP"
+testprofile 'spec-6' 'foo <stage1 !notest>' 'stage1' "$KEEP"
+testprofile 'spec-6' 'foo <stage1 !notest>' 'notest' "$DROP"
+testprofile 'spec-6' 'foo <stage1 !notest>' 'stage1,notest' "$DROP"
+
+testprofile 'spec-7' 'foo <stage1> <!notest>' '' "$KEEP"
+testprofile 'spec-7' 'foo <stage1> <!notest>' 'stage1' "$KEEP"
+testprofile 'spec-7' 'foo <stage1> <!notest>' 'notest' "$DROP"
+testprofile 'spec-7' 'foo <stage1> <!notest>' 'stage1,notest' "$KEEP"
diff --git a/test/libapt/parsedepends_test.cc b/test/libapt/parsedepends_test.cc
index 52eac8232..f644599bd 100644
--- a/test/libapt/parsedepends_test.cc
+++ b/test/libapt/parsedepends_test.cc
@@ -33,9 +33,10 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
"os-for-me [ linux-any ], "
"cpu-not-for-me [ any-armel ], "
"os-not-for-me [ kfreebsd-any ], "
- "not-in-stage1 <!profile.stage1>, "
- "not-in-stage1-or-nodoc <!profile.nodoc !profile.stage1>, "
- "only-in-stage1 <unknown.unknown profile.stage1>, "
+ "not-in-stage1 <!stage1>, "
+ "not-stage1-and-not-nodoc <!nodoc !stage1>, "
+ "not-stage1-or-not-nodoc <!nodoc> <!stage1>, "
+ "unknown-profile <unknown stage1>, "
"overlord-dev:any (= 7.15.3~) | overlord-dev:native (>> 7.15.5), "
;
@@ -184,7 +185,7 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
if (ParseRestrictionsList == true) {
Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
- EXPECT_EQ("", Package); // not-in-stage1-or-in-nodoc
+ EXPECT_EQ("", Package); // not-stage1-and-not-nodoc
} else {
EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
Start = strstr(Start, ",");
@@ -193,7 +194,16 @@ static void parseDependency(bool const StripMultiArch, bool const ParseArchFlag
if (ParseRestrictionsList == true) {
Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
- EXPECT_EQ("only-in-stage1", Package);
+ EXPECT_EQ("not-stage1-or-not-nodoc", Package);
+ } else {
+ EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
+ Start = strstr(Start, ",");
+ Start++;
+ }
+
+ if (ParseRestrictionsList == true) {
+ Start = debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList);
+ EXPECT_EQ("", Package); // unknown-profile
} else {
EXPECT_EQ(true, 0 == debListParser::ParseDepends(Start, End, Package, Version, Op, ParseArchFlags, StripMultiArch, ParseRestrictionsList));
Start = strstr(Start, ",");
@@ -232,10 +242,11 @@ test:
SCOPED_TRACE(std::string("ParseRestrictionsList: ") + (ParseRestrictionsList ? "true" : "false"));
parseDependency(StripMultiArch, ParseArchFlags, ParseRestrictionsList);
}
- if (StripMultiArch == false)
- if (ParseArchFlags == false)
- ParseRestrictionsList = !ParseRestrictionsList;
- ParseArchFlags = !ParseArchFlags;
+ if (StripMultiArch == false) {
+ if (ParseArchFlags == false)
+ ParseRestrictionsList = !ParseRestrictionsList;
+ ParseArchFlags = !ParseArchFlags;
+ }
StripMultiArch = !StripMultiArch;
runner++;