From 429effb963fba7529b8ff57d6b0474916d4fed69 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 10 Mar 2020 10:46:56 +0100 Subject: Don't crash pattern matching sections if pkg has no section Packages from third-party sources do not always follow the established patterns of more properly maintained archives. In that case it was a driver package for a scanner&printer device which has only a minimum of info attached, but also minimal non-installed packages do not include sections, so we really shouldn't assume their availability. --- apt-pkg/cachefilter-patterns.cc | 2 +- test/integration/test-apt-patterns | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc index 5a58a9767..bc0eece30 100644 --- a/apt-pkg/cachefilter-patterns.cc +++ b/apt-pkg/cachefilter-patterns.cc @@ -501,7 +501,7 @@ BaseRegexMatcher::BaseRegexMatcher(std::string const &Pattern) } bool BaseRegexMatcher::operator()(const char *string) { - if (unlikely(pattern == NULL)) + if (unlikely(pattern == nullptr) || string == nullptr) return false; else return regexec(pattern, string, 0, 0, 0) == 0; diff --git a/test/integration/test-apt-patterns b/test/integration/test-apt-patterns index cdba76146..b55caf35b 100755 --- a/test/integration/test-apt-patterns +++ b/test/integration/test-apt-patterns @@ -26,6 +26,18 @@ insertpackage 'unstable' 'foreign' 'amd64' '2.0' getoriginfromsuite() { echo -n 'meow'; } setupaptarchive +cat >> rootdir/var/lib/dpkg/status <