diff options
author | Heiko Hund | 2020-02-06 14:21:01 +0100 |
---|---|---|
committer | David Sommerseth | 2020-02-20 16:40:20 +0100 |
commit | 870e2405e27fb0c119ade6fc0032c81af4d89819 (patch) | |
tree | 2478ab59b8020a402ce316c43944bace8b82a05f /src/openvpn/socket.c | |
parent | 4ed7bf7f94a8cecbc2430d8025a2b8a46f94e429 (diff) | |
download | openvpn-870e2405e27fb0c119ade6fc0032c81af4d89819.zip openvpn-870e2405e27fb0c119ade6fc0032c81af4d89819.tar.gz |
argv: do fewer memory re-allocations
Prevent the re-allocations of memory when the internal argv grows
beyond 2 and 4 arguments by initially allocating argv to hold up to
7 (+ trailing NULL) pointers.
While at it rename argv_reset to argv_free to actually express
what's going on. Redo the argv_reset functionality so that it can
be used to actually reset the argv without re-allocation.
Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200206132103.15977-3-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19378.html
Diffstat (limited to 'src/openvpn/socket.c')
-rw-r--r-- | src/openvpn/socket.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index 983ed38..f2fb54d 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -2471,7 +2471,7 @@ link_socket_connection_initiated(const struct buffer *buf, { msg(M_WARN, "WARNING: ipchange plugin call failed"); } - argv_reset(&argv); + argv_free(&argv); } /* Process --ipchange option */ @@ -2481,7 +2481,7 @@ link_socket_connection_initiated(const struct buffer *buf, setenv_str(es, "script_type", "ipchange"); ipchange_fmt(true, &argv, info, &gc); openvpn_run_script(&argv, es, 0, "--ipchange"); - argv_reset(&argv); + argv_free(&argv); } gc_free(&gc); |