Prevent allocations of size 0 in sh_init.
authorGuido Vranken <guidovranken@gmail.com>
Mon, 13 Feb 2017 00:36:43 +0000 (01:36 +0100)
committerRich Salz <rsalz@openssl.org>
Tue, 14 Feb 2017 19:35:40 +0000 (14:35 -0500)
commitbe31d57686a551261cfd5deb95c9553402942a43
tree360af1d3c7b649a7ba95028e4c07c730451d5a22
parentdff827da751525b0e32ecb59a1d382b03f34a4de
Prevent allocations of size 0 in sh_init.

which are not possible with the default OPENSSL_zalloc, but are possible if
the user has installed their own allocator using CRYPTO_set_mem_functions. If
the 0-allocations succeeds, the secure heap code will later access
(at least) the first byte of that space, which is technically an OOB
access. This could lead to problems with some custom allocators that only
return a valid pointer for subsequent free()-ing, and do not expect that
the pointer is actually dereferenced.

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2605)
(cherry picked from commit 7f07149d25f8d7e00e9350ff2f064a4d25c1a13d)
crypto/mem_sec.c