VirtualBox

Changeset 33953 in vbox


Ignore:
Timestamp:
Nov 11, 2010 7:47:27 AM (14 years ago)
Author:
vboxsync
Message:

NAT/libalias: fixes issue with wrong type of query header in DNS respose, when host resolver mode is switched on (please see vbox/#7679 for details).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/slirp/libalias/alias_dns.c

    r32431 r33953  
    8686}
    8787
    88 static void doanswer(struct libalias *la, union dnsmsg_header *hdr,char *qname, struct ip *pip, struct hostent *h)
     88static void doanswer(struct libalias *la, union dnsmsg_header *hdr, uint16_t qtype, uint16_t qclass, char *qname, struct ip *pip, struct hostent *h)
    8989{
    9090    int i;
     
    121121        query += strlen(qname) + 1;
    122122
    123         *(uint16_t *)query = htons(1);
    124         ((uint16_t *)query)[1] = htons(1);
     123        *(uint16_t *)query = qtype;
     124        ((uint16_t *)query)[1] = qclass;
    125125        answers = (char *)&((uint16_t *)query)[2];
    126126
     
    199199    qw_qname = (char *)&hdr[1];
    200200    Assert((ntohs(hdr->X.qdcount) == 1));
     201    if ((ntohs(hdr->X.qdcount) != 1))
     202    {
     203        LogRel(("NAT:alias_dns: multiple quieries isn't supported\n"));
     204        return 1;
     205    }
    201206
    202207    for (i = 0; i < ntohs(hdr->X.qdcount); ++i)
     
    206211        fprintf(stderr, "qname:%s qtype:%hd qclass:%hd\n",
    207212            qw_qname, ntohs(*qw_qtype), ntohs(*qw_qclass));
    208     }
    209 
    210     QStr2CStr(qw_qname, cname, sizeof(cname));
    211     cname_len = RTStrNLen(cname, sizeof(cname));
    212     /* Some guests like win-xp adds _dot_ after host name
    213      * and after domain name (not passed with host resolver)
    214      * that confuses host resolver.
    215      */
    216     if (   cname_len > 2
    217         && cname[cname_len - 1] == '.'
    218         && cname[cname_len - 2] == '.')
    219     {
    220         cname[cname_len - 1] = 0;
    221         cname[cname_len - 2] = 0;
    222     }
    223     h = gethostbyname(cname);
    224     fprintf(stderr, "cname:%s\n", cname);
    225     doanswer(la, hdr, qw_qname, pip, h);
     213
     214        QStr2CStr(qw_qname, cname, sizeof(cname));
     215        cname_len = RTStrNLen(cname, sizeof(cname));
     216        /* Some guests like win-xp adds _dot_ after host name
     217         * and after domain name (not passed with host resolver)
     218         * that confuses host resolver.
     219         */
     220        if (   cname_len > 2
     221            && cname[cname_len - 1] == '.'
     222            && cname[cname_len - 2] == '.')
     223        {
     224            cname[cname_len - 1] = 0;
     225            cname[cname_len - 2] = 0;
     226        }
     227        h = gethostbyname(cname);
     228        fprintf(stderr, "cname:%s\n", cname);
     229        doanswer(la, hdr, *qw_qtype, *qw_qclass, qw_qname, pip, h);
     230    }
    226231
    227232    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette