mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-23 03:49:23 +00:00
Util: more checks in get_dns_txt_records_base
This commit is contained in:
parent
8699e1887c
commit
f4d709c0dd
1 changed files with 19 additions and 12 deletions
|
@ -508,6 +508,7 @@ bool get_dns_txt_records_base(const std::string& host, Callback<void, const char
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
try {
|
||||||
PDNS_RECORD pQueryResults;
|
PDNS_RECORD pQueryResults;
|
||||||
if (DnsQuery(host.c_str(), DNS_TYPE_TEXT, DNS_QUERY_STANDARD, NULL, &pQueryResults, NULL) != 0) {
|
if (DnsQuery(host.c_str(), DNS_TYPE_TEXT, DNS_QUERY_STANDARD, NULL, &pQueryResults, NULL) != 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -516,14 +517,20 @@ bool get_dns_txt_records_base(const std::string& host, Callback<void, const char
|
||||||
for (PDNS_RECORD p = pQueryResults; p; p = p->pNext) {
|
for (PDNS_RECORD p = pQueryResults; p; p = p->pNext) {
|
||||||
for (size_t j = 0; j < p->Data.TXT.dwStringCount; ++j) {
|
for (size_t j = 0; j < p->Data.TXT.dwStringCount; ++j) {
|
||||||
const char* s = p->Data.TXT.pStringArray[j];
|
const char* s = p->Data.TXT.pStringArray[j];
|
||||||
|
if (s) {
|
||||||
const size_t n = strlen(s);
|
const size_t n = strlen(s);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
callback(s, n);
|
callback(s, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DnsRecordListFree(pQueryResults, DnsFreeRecordList);
|
DnsRecordListFree(pQueryResults, DnsFreeRecordList);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#elif defined(HAVE_RES_QUERY)
|
#elif defined(HAVE_RES_QUERY)
|
||||||
|
|
Loading…
Reference in a new issue