res_send() doesn't work with osquery enabled

Pierre A. Humblet
Thu Aug 26 17:17:00 GMT 2010

----- Original Message ----- 
From: "Corinna Vinschen" 
To: <cygwin-patches>
Sent: Thursday, August 26, 2010 12:38

| Pierre, would you mind to take a look?
| On Aug 26 19:07, wrote:
| > Currently res_init() checks for availability of the native windows
| > function DnsQuery_A. If the function is found, it's preferred over the
| > cygwin implementation and res_query is set up to use it.
| > As DnsQuery_A finds the configured name servers itself, the current code
| > assumes we can avoid loading the dns server list with GetNetworkParams().
| > 
| > However, the assumption that everybody would use res_query is wrong. Some
| > programs may use res_mkquery() and res_send() or may only read the list of
| > servers from _res.nsaddr_list and send/receive the queries/replies
| > themselves. res_send() also relies on nsaddr_list.

It's true that the behavior described above is legitimate, even if nobody had ever 
requested it. If people want to access nsaddr_list after calling res_ninit, loading 
iphlpapi.dll every time (as the patch does) is unavoidable.

The other change has res_nsend return an error if no server can be found.
Alternatively the error could be reported by res_ninit, by removing the second
condition in 
if (statp->nscount == 0 && !statp->os_query) {
    errno = ENONET;
    statp->res_h_errno = NETDB_INTERNAL;

Hypothetically this could affect some installations where iphlpapi doesn't report any
servers although the Windows resolver can find a server (but I don't see how this
could happen), so it's safer to proceed as in the patch.
However the patch should send errno to ENONET and set res_h_errno to

Except for the previous comment, I am fine with the patch.


More information about the Cygwin-patches mailing list