[klibc] calloc: Fail if multiplication overflows
authorBen Hutchings <ben@decadent.org.uk>
Wed, 28 Apr 2021 02:29:50 +0000 (04:29 +0200)
committerThorsten Glaser <tg@mirbsd.de>
Wed, 26 May 2021 22:12:10 +0000 (23:12 +0100)
commitd8ff251ca688c11a9e986ce10ad381c3391d0261
treef81817ec7593ce71b2e78cb07a6470b54b423b67
parenteb80eb61e064fd62f1eff968d9d6558eb36d1f0b
[klibc] calloc: Fail if multiplication overflows

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

calloc() multiplies its 2 arguments together and passes the result to
malloc().  Since the factors and product both have type size_t, this
can result in an integer overflow and subsequent buffer overflow.
Check for this and fail if it happens.

CVE-2021-31870

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0037-klibc-calloc-Fail-if-multiplication-overflows.patch
usr/klibc/calloc.c