[klibc] cpio: Fix possible integer overflow on 32-bit systems
authorBen Hutchings <ben@decadent.org.uk>
Wed, 28 Apr 2021 03:16:34 +0000 (05:16 +0200)
committerThorsten Glaser <tg@mirbsd.de>
Wed, 26 May 2021 22:12:10 +0000 (23:12 +0100)
commitd1101bf410742ad29fb13a2ff310fe656342dce1
treeb2bd514712312e6c7020c63f444ee2f22a5bcf82
parentd8ff251ca688c11a9e986ce10ad381c3391d0261
[klibc] cpio: Fix possible integer overflow on 32-bit systems

Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=9b1c91577aef7f2e72c3aa11a27749160bd278ff
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2021-31872

The maximum name and file sizes in the "new" header format are 32-bit
unsigned values.  However, the I/O functions mostly use long for sizes
and offsets, so that sizes >= 2^31 are handled wrongly on 32-bit
systems.

The current GNU cpio code doesn't seem to have this problem, but the
divergence between this version and that is large enough that I can't
simply cherry-pick a fix for it.

As a short-term fix, in read_in_new_ascii(), fail if c_namesize or
c_filesize is > LONG_MAX.

CVE-2021-31872

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0039-klibc-cpio-Fix-possible-integer-overflow-on-32-bit-s.patch
usr/utils/cpio.c