diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-02-20 13:25:10 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-02-20 13:35:27 +0100 |
commit | 942be407ee8b6ca1089ed9c2f135ca4ed89c44fc (patch) | |
tree | e9002997b12456b3a1a496a0cfb5f2a8dc3e231a /apt-pkg | |
parent | c8821bb424e2324a36896dcccaef573c938c5b0e (diff) |
tagfile: Check if memchr() returned null before using
This fixes a segmentation fault trying to read from nullptr+1,
aka address 1.
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/tagfile.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index bbece1d7e..b86936353 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -714,8 +714,13 @@ StringView pkgTagSection::Find(Key key) const StringView pkgTagSection::FindRawInternal(unsigned int Pos) const { char const *Start = (char const *) memchr(Section + d->Tags[Pos].EndTag, ':', d->Tags[Pos].StartValue - d->Tags[Pos].EndTag); - ++Start; char const *End = Section + d->Tags[Pos + 1].StartTag; + + if (Start == nullptr) + return ""; + + ++Start; + if (unlikely(Start > End)) return ""; |