Skip to content

Commit 154e8a5

Browse files
saddamr3ecron2
authored andcommitted
dns: Fix memory leak in dns_server_addr_parse
When the DNS server's address count is already full (exceeds the limit of 8), the function returned early without freeing the successfully resolved addrinfo struct. Fix this by checking the limit before executing the DNS lookup. Github: #1055 Change-Id: I7ec318c86af994284d1c6272e3bbe2b1ede160fd Signed-off-by: saddamr3e <saddamr3e@gmail.com> Acked-by: Heiko Hund <heiko@openvpn.net> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1712 Message-Id: <20260618061835.16448-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg37209.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
1 parent 1281d26 commit 154e8a5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/openvpn/dns.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ dns_server_addr_parse(struct dns_server *server, const char *addr)
114114
addr = addrcopy;
115115
}
116116

117-
struct addrinfo *ai = NULL;
118-
if (openvpn_getaddrinfo(0, addr, NULL, 0, NULL, af, &ai) != 0)
117+
if (server->addr_count >= SIZE(server->addr))
119118
{
120119
return false;
121120
}
122121

123-
if (server->addr_count >= SIZE(server->addr))
122+
struct addrinfo *ai = NULL;
123+
if (openvpn_getaddrinfo(0, addr, NULL, 0, NULL, af, &ai) != 0)
124124
{
125125
return false;
126126
}

0 commit comments

Comments
 (0)