mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
libunbound has const correctness issues...
This commit is contained in:
parent
06a4578bf2
commit
738357459b
1 changed files with 19 additions and 5 deletions
|
@ -27,6 +27,7 @@
|
|||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "common/dns_utils.h"
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <ldns/rr.h> // for RR type and class defs
|
||||
#include <unbound.h>
|
||||
|
@ -99,9 +100,11 @@ DNSResolver::DNSResolver() : m_data(new DNSResolverData())
|
|||
// init libunbound context
|
||||
m_data->m_ub_context = ub_ctx_create();
|
||||
|
||||
char empty_string = '\0';
|
||||
|
||||
// look for "/etc/resolv.conf" and "/etc/hosts" or platform equivalent
|
||||
ub_ctx_resolvconf(m_data->m_ub_context, "");
|
||||
ub_ctx_hosts(m_data->m_ub_context, "");
|
||||
ub_ctx_resolvconf(m_data->m_ub_context, &empty_string);
|
||||
ub_ctx_hosts(m_data->m_ub_context, &empty_string);
|
||||
}
|
||||
|
||||
DNSResolver::~DNSResolver()
|
||||
|
@ -119,7 +122,10 @@ DNSResolver::~DNSResolver()
|
|||
std::vector<std::string> DNSResolver::get_ipv4(const std::string& url)
|
||||
{
|
||||
std::vector<std::string> addresses;
|
||||
char urlC[1000]; // waaaay too big, but just in case...
|
||||
|
||||
strncpy(urlC, url.c_str(), 999);
|
||||
urlC[999] = '\0';
|
||||
if (!check_address_syntax(url))
|
||||
{
|
||||
return addresses;
|
||||
|
@ -129,7 +135,7 @@ std::vector<std::string> DNSResolver::get_ipv4(const std::string& url)
|
|||
ub_result_ptr result;
|
||||
|
||||
// call DNS resolver, blocking. if return value not zero, something went wrong
|
||||
if (!ub_resolve(m_data->m_ub_context, url.c_str(), LDNS_RR_TYPE_A, LDNS_RR_CLASS_IN, &(result.ptr)))
|
||||
if (!ub_resolve(m_data->m_ub_context, urlC, LDNS_RR_TYPE_A, LDNS_RR_CLASS_IN, &(result.ptr)))
|
||||
{
|
||||
if (result.ptr->havedata)
|
||||
{
|
||||
|
@ -146,6 +152,10 @@ std::vector<std::string> DNSResolver::get_ipv4(const std::string& url)
|
|||
std::vector<std::string> DNSResolver::get_ipv6(const std::string& url)
|
||||
{
|
||||
std::vector<std::string> addresses;
|
||||
char urlC[1000]; // waaaay too big, but just in case...
|
||||
|
||||
strncpy(urlC, url.c_str(), 999);
|
||||
urlC[999] = '\0';
|
||||
|
||||
if (!check_address_syntax(url))
|
||||
{
|
||||
|
@ -155,7 +165,7 @@ std::vector<std::string> DNSResolver::get_ipv6(const std::string& url)
|
|||
ub_result_ptr result;
|
||||
|
||||
// call DNS resolver, blocking. if return value not zero, something went wrong
|
||||
if (!ub_resolve(m_data->m_ub_context, url.c_str(), LDNS_RR_TYPE_AAAA, LDNS_RR_CLASS_IN, &(result.ptr)))
|
||||
if (!ub_resolve(m_data->m_ub_context, urlC, LDNS_RR_TYPE_AAAA, LDNS_RR_CLASS_IN, &(result.ptr)))
|
||||
{
|
||||
if (result.ptr->havedata)
|
||||
{
|
||||
|
@ -172,6 +182,10 @@ std::vector<std::string> DNSResolver::get_ipv6(const std::string& url)
|
|||
std::vector<std::string> DNSResolver::get_txt_record(const std::string& url)
|
||||
{
|
||||
std::vector<std::string> records;
|
||||
char urlC[1000]; // waaaay too big, but just in case...
|
||||
|
||||
strncpy(urlC, url.c_str(), 999);
|
||||
urlC[999] = '\0';
|
||||
|
||||
if (!check_address_syntax(url))
|
||||
{
|
||||
|
@ -181,7 +195,7 @@ std::vector<std::string> DNSResolver::get_txt_record(const std::string& url)
|
|||
ub_result_ptr result;
|
||||
|
||||
// call DNS resolver, blocking. if return value not zero, something went wrong
|
||||
if (!ub_resolve(m_data->m_ub_context, url.c_str(), LDNS_RR_TYPE_TXT, LDNS_RR_CLASS_IN, &(result.ptr)))
|
||||
if (!ub_resolve(m_data->m_ub_context, urlC, LDNS_RR_TYPE_TXT, LDNS_RR_CLASS_IN, &(result.ptr)))
|
||||
{
|
||||
if (result.ptr->havedata)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue