lib/dpkg/tarfn.c: Kludge `tar_header_decode' to handle spurious `errno'. mdw/enomem-fix 1.18.25mdw1
authorMark Wooding <mdw@distorted.org.uk>
Thu, 18 Jun 2020 17:35:01 +0000 (18:35 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 18 Jun 2020 17:36:34 +0000 (18:36 +0100)
commit07c08054b0c72279834184ce3a4f042fd8c4278e
tree57329d14cac829dd260c787804f07d3133a17637
parent1479465fc773f05c382dec082c624ddfd6d269be
lib/dpkg/tarfn.c: Kludge `tar_header_decode' to handle spurious `errno'.

This fixes a curious failure unpacking `gnome-icon-theme' under qemu.
What appears to be happening here is that `m_strndup' (or, more likely,
`malloc' behind it) is setting `errno' to `ENOMEM' while it tries
various approaches to allocating memory.  This then confuses the
`if (errno)' check at the end into thinking that the header decoding has
failed when in fact everything is fine.

POSIX appears to allow `malloc', and derived functions, to set `errno'
spuriously in this manner (even though ISO C rules wouldn't given the
POSIX definition of `malloc'), so this is properly a bug in `dpkg'.

This bug is fixed (by accident, apparently) in buster, but the proper
change is hard to backport, so we have this kludge instead.
debian/changelog
lib/dpkg/tarfn.c