]> git.ipfire.org Git - thirdparty/openvpn.git/commit
create_temp_file/gen_path: prevent memory leak if gc == NULL
authorSteffan Karger <steffan@karger.me>
Wed, 1 Nov 2017 22:03:42 +0000 (23:03 +0100)
committerGert Doering <gert@greenie.muc.de>
Fri, 24 Nov 2017 12:29:04 +0000 (13:29 +0100)
commitbd89ebd6a82856c7939b4ade35d14d0178a96986
treee2420b80789a7f302c89d79f857f2fcd59b0a1f1
parent3e0fd2b0471cf4e53959902ca10d88db7a1ef916
create_temp_file/gen_path: prevent memory leak if gc == NULL

If gc == NULL, the data allocated in the alloc_gc_buf() call in
create_temp_file or the string_mod_const call in gen_path would never
be free'd.

These functions are currently never called that way, but let's prevent
future problems.

While touching create_temp_file, also remove the counter variable, which is
never read, simplify the do-while to a while loop, and truncate the prefix
(if needed) to preserve the random and extension of the created filename.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20171101220342.14648-5-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15703.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/misc.c