]> git.saurik.com Git - apt.git/commit
TagFile: Fix off-by-one errors in comment stripping
authorJulian Andres Klode <jak@debian.org>
Wed, 31 Aug 2016 15:01:04 +0000 (17:01 +0200)
committerJulian Andres Klode <jak@debian.org>
Wed, 5 Oct 2016 19:53:38 +0000 (21:53 +0200)
commit43ed244f35c0bbd3bec2dae0d5e71d98f6314d23
tree79230ea1e345407cab6a72cbfee23a170f75517e
parentb9cddcfb31dd6da49fcd470aaa484eafcfc779ae
TagFile: Fix off-by-one errors in comment stripping

Adding 1 to the value of d->End - current makes restLength one byte
too long: If we pass memchr(current, ..., restLength) has thus
undefined behavior.

Also, reading the value of current has undefined behavior if
current >= d->End, not only for current > d->End:

Consider a string of length 1, that is d->End = d->Current + 1.
We can only read at d->Current + 0, but d->Current + 1 is beyond
the end of the string.

This probably caused several inexplicable build failures on hurd-i386
in the past, and just now caused a build failure on Ubuntu's amd64
builder.

Reported-By: valgrind
(cherry picked from commit 923c592ceb6014b31ec751b97b3ed659fa3e88ae)
apt-pkg/tagfile.cc