]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Clean up format_hex_ex()
authorSteffan Karger <steffan.karger@fox-it.com>
Mon, 28 Nov 2016 16:55:07 +0000 (17:55 +0100)
committerGert Doering <gert@greenie.muc.de>
Mon, 28 Nov 2016 17:35:06 +0000 (18:35 +0100)
commit384302478f967e4fbb5e4d813eb30a5c15d00a14
treec79a789e616f58f024fb8285990c381763b7db42
parentd5cb6b4948b9bb64684e6be800d2cbaaf3c32768
Clean up format_hex_ex()

Cherry-pick of commit 29404010 from master, slightly reworked to match the
2.3 codebase (no flags inside space_break here), and pulled in the new
static_assert() fallback we also have in master now.

Fix a potential null-pointer dereference, and make the code a bit more
readable while doing so.

The NULL dereference could not be triggered, because the current code
never called format_hex_ex() with maxouput == 0 and separator == NULL.
But it's nicer to not depend on that.

Our use of int vs size_t for lengths needs some attention too, but I'm
not pulling that into this patch.  Instead I decided to just make the
(previously existing) assumption that INT_MAX <= SIZE_MAX explicit by
adding a static_assert().

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