From: Willem Toorop Date: Tue, 28 Jun 2011 12:15:32 +0000 (+0000) Subject: Bugfix 394 of leaking sockets: X-Git-Tag: release-1.6.11rc1~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f24b14cd6aeb301a116f15a407b8c9c532929b5f;p=thirdparty%2Fldns.git Bugfix 394 of leaking sockets: when ldns_udp_send_query returned a error when used from ldns_udp_bgsend and ldns_tcp_bgsend, the newly created socket was not closed nor returned. Now it is closed. --- diff --git a/Changelog b/Changelog index 62743918..4a898785 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 1.6.11 + * bugfix #394: Fix socket leak on errors 1.6.10 2011-05-31 * New example tool added: ldns-gen-zone. diff --git a/net.c b/net.c index bf8766b9..8bae0b2c 100644 --- a/net.c +++ b/net.c @@ -341,6 +341,11 @@ ldns_udp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t } if (ldns_udp_send_query(qbin, sockfd, to, tolen) == 0) { + #ifndef USE_WINSOCK + close(sockfd); + #else + closesocket(sockfd); + #endif return 0; } return sockfd; @@ -678,6 +683,11 @@ ldns_tcp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t } if (ldns_tcp_send_query(qbin, sockfd, to, tolen) == 0) { + #ifndef USE_WINSOCK + close(sockfd); + #else + closesocket(sockfd); + #endif return 0; }