Skip to content

Instantly share code, notes, and snippets.

@aliceinwire
Created November 21, 2012 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliceinwire/4123963 to your computer and use it in GitHub Desktop.
Save aliceinwire/4123963 to your computer and use it in GitHub Desktop.
zabbix-2.0.3-dnsapi.patch
--- zabbix-2.0.3.orig/src/libs/zbxsysinfo/common/net.c 2012-11-05 07:04:04.450140996 +0900
+++ zabbix-2.0.3/src/libs/zbxsysinfo/common/net.c 2012-11-16 13:19:28.057641634 +0900
@@ -215,6 +215,8 @@ static int dns_query(const char *cmd, co
PDNS_RECORD pQueryResults, pDnsRecord;
LPTSTR wzone;
char tmp2[MAX_STRING_LEN];
+ static HMODULE dnsapi_dllHandle = NULL;
+ static void (WINAPI *DnsRecordListFree_dyn)(PDNS_RECORD, DNS_FREE_TYPE) = NULL;
#else
char *name;
unsigned char *msg_end, *msg_ptr, *p;
@@ -657,8 +659,14 @@ static int dns_query(const char *cmd, co
#ifdef _WINDOWS
clean:
+ if (NULL == dnsapi_dllHandle)
+ dnsapi_dllHandle = LoadLibrary(L"Dnsapi.dll");
+ //Get pointer to our function using GetProcAddress:
+ if (NULL != dnsapi_dllHandle && NULL == DnsRecordListFree_dyn)
+ (FARPROC)DnsRecordListFree_dyn = GetProcAddress(dnsapi_dllHandle, "DnsRecordListFree");
+
if (DNS_RCODE_NOERROR == res)
- DnsRecordListFree(pQueryResults, DnsFreeRecordList);
+ DnsRecordListFree_dyn(pQueryResults, DnsFreeRecordList);
#endif
return ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment