HomeFreeBSD

MFC r327674, r327796

Description

MFC r327674, r327796

Introduce mallocarray() in the kernel

Similar to calloc() the mallocarray() function checks for integer
overflows before allocating memory.
It does not zero memory, unless the M_ZERO flag is set.

Additionally, move the overflow check logic out to WOULD_OVERFLOW() for
consumers to have a common means of testing for overflowing allocations.
WOULD_OVERFLOW() should be a secondary check -- on 64-bit platforms, just
because an allocation won't overflow size_t does not mean it is a sane size
to request. Callers should be imposing reasonable allocation limits far,
far, below overflow.

Obtained from: OpenBSD

Details

Provenance
kpAuthored on
Parents
rS328209: termcap: add xterm-termite
Branches
Unknown
Tags
Unknown