Hi,
the patch looks about right – some things I would write differently,
namely taking advantage of c++11 and such and cppcheck has some
suggestions (which are basically "complains" about the used c89 style),
too, but nothing major which would prevent me from applying it [after
this casual look]. (A testcase would be nice through). Thanks a lot!
I would very much prefer support to land in dpkg before applying it in
apt through as our tar extraction is 'just' there for apt-ftparchive and
apt-extracttemplates, so not used 'much' (so I have less qualms about
applying 'any' 'random' patch to it – all relative of course as this is
still code run on most Debian systems, but not as critical as other
parts) while extraction is a bread-and-butter thing for dpkg and gets
hence a much better look from someone who actually works with tar much.
So: please go ahead with extending dpkg – apt will follow suit then!