From 7ddf958e370d13f93edc6923bee289b2f6444b41 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 30 May 2017 22:24:14 +0200 Subject: Fix parsing of or groups in build-deps with ignored packages If the last alternative(s) of an Or group is ignored, because it does not match an architecture list, we would end up keeping the or flag, effectively making the next AND an OR. For example, when parsing (on amd64): debhelper (>= 9), libnacl-dev [amd64] | libnacl-dev [i386] => debhelper (>= 9), libnacl-dev | Which can cause python-apt to crash. Even worse: debhelper (>= 9), libnacl-dev [amd64] | libnacl-dev [i386], foobar => debhelper (>= 9), libnacl-dev [amd64] | foobar By setting the previous alternatives Or flag to the current Or flag if the current alternative is ignored, we solve the issue. LP: #1694697 --- apt-pkg/deb/debsrcrecords.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'apt-pkg/deb') diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc index 5f0a75cd9..d664b609e 100644 --- a/apt-pkg/deb/debsrcrecords.cc +++ b/apt-pkg/deb/debsrcrecords.cc @@ -129,8 +129,18 @@ bool debSrcRecordParser::BuildDepends(std::vectorError("Problem parsing dependency: %s", fields[I]); rec.Type = I; - if (rec.Package != "") + // We parsed a package that was ignored (wrong architecture restriction + // or something). + if (rec.Package == "") { + // If we are in an OR group, we need to set the "Or" flag of the + // previous entry to our value. + if (BuildDeps.size() > 0 && (BuildDeps[BuildDeps.size() - 1].Op & pkgCache::Dep::Or) == pkgCache::Dep::Or) { + BuildDeps[BuildDeps.size() - 1].Op &= ~pkgCache::Dep::Or; + BuildDeps[BuildDeps.size() - 1].Op |= (rec.Op & pkgCache::Dep::Or); + } + } else { BuildDeps.push_back(rec); + } if (Start == Stop) break; -- cgit v1.2.3