]> git.ipfire.org Git - thirdparty/openvpn.git/commit
buffer_list_aggregate_separator(): prevent 0-byte malloc
authorSteffan Karger <steffan.karger@fox-it.com>
Fri, 29 Dec 2017 09:54:00 +0000 (10:54 +0100)
committerGert Doering <gert@greenie.muc.de>
Thu, 11 Jan 2018 11:33:23 +0000 (12:33 +0100)
commit748902f46260fe11cb25726d2bf93bb06ad338f2
treed9f84ed2d25b8e03bb9bc22178980501dda8dc18
parentfb6138dd32cf01922d7ef670d502148596511268
buffer_list_aggregate_separator(): prevent 0-byte malloc

As pointed out in finding OVPN-05 of the cryptograpy engineering audit
(funded by Private Internet Access), buffer_list_aggregate_separator()
could perform a 0-byte malloc when called with a list of 0-length buffers
and a "" separator.  If other could would later try to access that buffer
memory, this would result in undefined behaviour.  To prevent this, always
malloc() 1 byte.

To simplify as we go, use alloc_buf() to allocate the buffer.  This has
the additional benefit that the actual buffer data (not the contents) is
zero-terminated, because alloc_buf() calls calloc() and we have 1 extra
byte of data.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541240-19536-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16106.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/buffer.c