From 7d0b0134ee443539f04a18b0ef7f01e92af149b3 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 12 Jan 2015 16:38:02 +0000 Subject: [PATCH] * minires-os-if.c (cygwin_query): Change questions into answers. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/libc/minires-os-if.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7328e003b..97280a09f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-01-12 Pierre A. Humblet + + * minires-os-if.c (cygwin_query): Change questions into answers. + 2015-01-08 Corinna Vinschen * cygheap.h (cygheap_pwdgrp::get_shell): Add sid to argument list. diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 94460ffb2..05fc95f5f 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -249,6 +249,13 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty rr = pQueryResultsSet; section = 0; while (rr) { + /* Some Windows versions return questions when providing locally generated + answers, for example for "localhost" or for the computer name. */ + if (((rr->Flags.DW & 0x3) == DnsSectionQuestion) && + (rr->wDataLength > 0)) { + DPRINTF(debug, "Changing record below from question to answer\n"); + rr->Flags.DW ^= DnsSectionQuestion ^ DnsSectionAnswer; + } if (!counts[0] && (rr->Flags.DW & 0x3)) { /* No question. Adopt the first name as the name in the question */ if ((len = dn_comp(rr->pName, ptr, AnsLength - 4,