summaryrefslogtreecommitdiffstats
path: root/lib/libtls/tls_config.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2016-08-13 13:15:53 +0000
committerjsing <jsing@openbsd.org>2016-08-13 13:15:53 +0000
commit85212ddebea487445ab5fb1d281eeff4ed07824c (patch)
tree441b298da6cf3ecc9de3a00b1b01fb254a1692c8 /lib/libtls/tls_config.c
parentLet libtls load the CA, certificate and key files for nc(1), now that it (diff)
downloadwireguard-openbsd-85212ddebea487445ab5fb1d281eeff4ed07824c.tar.xz
wireguard-openbsd-85212ddebea487445ab5fb1d281eeff4ed07824c.zip
Avoid leaking memory if tls_config_set_alpn() is called multiple times
(this was in the original commit, but got reverted in the recommit).
Diffstat (limited to 'lib/libtls/tls_config.c')
-rw-r--r--lib/libtls/tls_config.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libtls/tls_config.c b/lib/libtls/tls_config.c
index cd2a04cdd6b..0d52704aa81 100644
--- a/lib/libtls/tls_config.c
+++ b/lib/libtls/tls_config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tls_config.c,v 1.26 2016/08/13 13:05:51 jsing Exp $ */
+/* $OpenBSD: tls_config.c,v 1.27 2016/08/13 13:15:53 jsing Exp $ */
/*
* Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
*
@@ -311,6 +311,10 @@ tls_config_parse_alpn(struct tls_config *config, const char *alpn,
char *s = NULL;
char *p, *q;
+ free(*alpn_data);
+ *alpn_data = NULL;
+ *alpn_len = 0;
+
if ((buf_len = strlen(alpn) + 1) > 65535) {
tls_config_set_errorx(config, "alpn too large");
goto err;
@@ -355,9 +359,6 @@ tls_config_parse_alpn(struct tls_config *config, const char *alpn,
free(buf);
free(s);
- *alpn_data = NULL;
- *alpn_len = 0;
-
return (-1);
}