]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
kdig: fixed memory leak due to bogus TLS input
authorMark Karpilovskij <mark.karpilovskij@nic.cz>
Thu, 18 Jan 2018 14:04:26 +0000 (15:04 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Thu, 18 Jan 2018 19:16:29 +0000 (20:16 +0100)
src/utils/common/netio.c

index 8c72cd9185043dd0a3bad62bf09293a0782ab39a..892371713ac687f3ca8aa0424f90d3eaf94a14a8 100644 (file)
@@ -1,4 +1,4 @@
-/*  Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
 
     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -177,6 +177,7 @@ int net_init(const srv_info_t    *local,
 
        // Get remote address list.
        if (get_addr(remote, iptype, socktype, &net->remote_info) != 0) {
+               net_clean(net);
                return KNOT_NET_EADDR;
        }
 
@@ -186,6 +187,7 @@ int net_init(const srv_info_t    *local,
        // Get local address if specified.
        if (local != NULL) {
                if (get_addr(local, iptype, socktype, &net->local_info) != 0) {
+                       net_clean(net);
                        return KNOT_NET_EADDR;
                }
        }
@@ -202,6 +204,7 @@ int net_init(const srv_info_t    *local,
        if (tls_params != NULL && tls_params->enable) {
                int ret = tls_ctx_init(&net->tls, tls_params, net->wait);
                if (ret != KNOT_EOK) {
+                       net_clean(net);
                        return ret;
                }
        }