ensure that pkgTagFile isn't writing past Buffer length
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 15 Aug 2013 14:49:51 +0000 (16:49 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 15 Aug 2013 15:39:24 +0000 (17:39 +0200)
commit0aae6d14390193e25ab6d0fd49295bd7b131954f
tree35c63ba45e67bdee4d074a955cf3d3011841cc89
parent037374fe7260c104771d1b6d31c36a98385c2365
ensure that pkgTagFile isn't writing past Buffer length

In 91c4cc14d3654636edf997d23852f05ad3de4853 I removed the +256 from
the pkgTagFile call parsing Release files as I couldn't find a
mentioning of a reason for why and it was marked as XXX which suggested
that at least someone else was suspicious.

It turns out that it is indeed "documented", it just didn't found it at
first but the changelog of apt 0.6.6 (29. Dec 2003) mentions:
  * Restore the ugly hack I removed from indexRecords::Load which set the
    pkgTagFile buffer size to (file size)+256.  This is concealing a bug,
    but I can't fix it right now.  This should fix the segfaults that
    folks are seeing with 0.6.[45].

The bug it is "hiding" is that if pkgTagFile works with a file which doesn't
end in a double newline it will be adding it without checking if the Buffer
is big enough to store them. Its also not a good idea to let the End
pointer be past the end of our space, even if we don't access the data.

Closes: 719629
apt-pkg/tagfile.cc
apt-pkg/tagfile.h