VirtualBox

Changeset 18225 in vbox


Ignore:
Timestamp:
Mar 24, 2009 7:56:11 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
44950
Message:

get_dns_addr_domain: wcstombs returns the size without counting the terminator.

File:
1 edited

Legend:

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

    r17656 r18225  
    101101    } while (0)
    102102# else /* !RT_OS_WINDOWS */
    103 #  ifdef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC 
     103#  ifdef VBOX_WITH_SIMPLIFIED_SLIRP_SYNC
    104104#   define DO_WIN_CHECK_FD_SET(so, events, fdset ) DO_CHECK_FD_SET((so), (events), fdset)
    105105#  else /* VBOX_WITH_SIMPLIFIED_SLIRP_SYNC */
     
    335335    struct dns_entry *da = NULL;
    336336    ULONG ret = ERROR_SUCCESS;
    337    
     337
    338338    /* @todo add SKIPing flags to get only required information */
    339339
    340340    ret = pData->pfGetAdaptersAddresses(AF_INET, 0, NULL /* reserved */, addresses, &size);
    341     if (ret != ERROR_BUFFER_OVERFLOW) 
     341    if (ret != ERROR_BUFFER_OVERFLOW)
    342342    {
    343343        LogRel(("NAT: error %lu occured on capacity detection operation\n", ret));
    344344        return -1;
    345345    }
    346    
    347     if (size == 0) 
     346
     347    if (size == 0)
    348348    {
    349349        LogRel(("NAT: Win socket API returns non capacity\n"));
    350350        return -1;
    351351    }
    352    
     352
    353353    addresses = RTMemAllocZ(size);
    354     if (addresses == NULL) 
     354    if (addresses == NULL)
    355355    {
    356356        LogRel(("NAT: No memory available \n"));
     
    362362    {
    363363        LogRel(("NAT: error %lu occured on fetching adapters info\n", ret));
    364         return -1; 
     364        return -1;
    365365    }
    366366    addr = addresses;
    367     while(addr != NULL) 
     367    while(addr != NULL)
    368368    {
    369369        size_t buff_size;
     
    371371            goto next;
    372372        dns = addr->FirstDnsServerAddress;
    373         while (dns != NULL) 
     373        while (dns != NULL)
    374374        {
    375375            struct sockaddr *saddr = dns->Address.lpSockaddr;
     
    386386            if ((((struct sockaddr_in *)saddr)->sin_addr.s_addr & htonl(IN_CLASSA_NET)) == ntohl(INADDR_LOOPBACK & IN_CLASSA_NET)) {
    387387                da->de_addr.s_addr = htonl(ntohl(special_addr.s_addr) | CTL_ALIAS);
    388             } 
    389             else 
     388            }
     389            else
    390390            {
    391391                da->de_addr.s_addr = ((struct sockaddr_in *)saddr)->sin_addr.s_addr;
    392392            }
    393393            LIST_INSERT_HEAD(&pData->dns_list_head, da, de_list);
    394         next_dns:   
     394        next_dns:
    395395            dns = dns->Next;
    396396        }
    397397        buff_size = wcstombs(NULL, addr->DnsSuffix, 0);
    398         if (buff_size == 0) 
     398        if (buff_size == 0)
    399399            goto next;
    400         suffix = RTMemAllocZ(buff_size);
     400        suffix = RTMemAllocZ(buff_size + 1);
    401401        wcstombs(suffix, addr->DnsSuffix, buff_size);
    402402        LogRel(("NAT: adding %s to DNS suffix list\n", suffix));
    403403        *ppszDomain = suffix;
    404         next:
     404    next:
    405405        addr = addr->Next;
    406406    }
    407407    /*@todo add dns suffix if required */
    408408    LogRel(("NAT: adding dns suffix %s to the list \n", ppszDomain));
    409     return 0; 
     409    return 0;
    410410}
    411411# endif /* VBOX_WITH_MULTI_DNS */
     
    871871#ifdef VBOX_WITH_SLIRP_DNS_PROXY
    872872                    Log2(("NAT: %R[natsock] expired\n", so));
    873                     if (so->so_timeout != NULL) 
     873                    if (so->so_timeout != NULL)
    874874                    {
    875875                        so->so_timeout(pData, so, so->so_timeout_arg);
    876                     } 
     876                    }
    877877#endif
    878878#ifdef VBOX_WITH_SLIRP_MT
     
    12071207                inq = outq = 0;
    12081208                status = getsockopt(so->s, SOL_SOCKET, SO_ERROR, &err, &optlen);
    1209                 if (status != 0) 
     1209                if (status != 0)
    12101210                    Log(("NAT: can't get error status from %R[natsock]\n", so));
    12111211#ifndef RT_OS_SOLARIS
     
    12171217                }
    12181218                status = ioctl(so->s, TIOCOUTQ, &outq); /* SIOCOUTQ see previous comment */
    1219                 if (status != 0) 
     1219                if (status != 0)
    12201220                    Log(("NAT: can't get depth of OUT queue from %R[natsock]\n", so));
    12211221#else
    12221222                /*
    12231223                 * Solaris has bit different ioctl commands and its handlings
    1224                  * hint: streamio(7) I_NREAD 
     1224                 * hint: streamio(7) I_NREAD
    12251225                 */
    12261226#endif
     
    12291229                {
    12301230                    /**
    1231                      * Check if we need here take care about gracefull connection 
     1231                     * Check if we need here take care about gracefull connection
    12321232                     * @todo try with proxy server
    12331233                     */
     
    12351235                    {
    12361236                        /*
    1237                          * Never meet inq != 0 or outq != 0, anyway let it stay for a while 
    1238                          * in case it happens we'll able to detect it. 
    1239                          * Give TCP/IP stack wait or expire the socket. 
     1237                         * Never meet inq != 0 or outq != 0, anyway let it stay for a while
     1238                         * in case it happens we'll able to detect it.
     1239                         * Give TCP/IP stack wait or expire the socket.
    12401240                         */
    12411241                        Log(("NAT: %R[natsock] err(%d:%s) s(in:%d,out:%d)happens on read I/O, "
     
    12471247                if (   !UNIX_CHECK_FD_SET(so, NetworkEvents, readfds)
    12481248                    && !UNIX_CHECK_FD_SET(so, NetworkEvents, writefds)
    1249                     && !UNIX_CHECK_FD_SET(so, NetworkEvents, xfds)) 
     1249                    && !UNIX_CHECK_FD_SET(so, NetworkEvents, xfds))
    12501250                {
    12511251                    Log(("NAT: system expires the socket %R[natsock] err(%d:%s) s(in:%d,out:%d) happens on non-I/O. ",
     
    12541254                }
    12551255                Log(("NAT: %R[natsock] we've met(%d:%s) s(in:%d, out:%d) unhandled combination hup (%d) "
    1256                     "rederr(%d) on (r:%d, w:%d, x:%d)\n", 
     1256                    "rederr(%d) on (r:%d, w:%d, x:%d)\n",
    12571257                        so, err, strerror(err),
    12581258                        inq, outq,
     
    12621262                        UNIX_CHECK_FD_SET(so, ign, writefds),
    12631263                        UNIX_CHECK_FD_SET(so, ign, xfds)));
    1264                 /* 
     1264                /*
    12651265                 * Give OS's TCP/IP stack a chance to resolve an issue or expire the socket.
    12661266                 */
     
    16481648    uint16_t hdport, hsport, service;
    16491649    hdport = ntohs(dport);
    1650     hsport = ntohs(sport); 
     1650    hsport = ntohs(sport);
    16511651    Log2(("proto: %d, dport: %d sport: %d\n", proto, hdport, hsport));
    16521652    service = 0;
    16531653#if 0
    16541654    /* Always return 0 here */
    1655     switch (hdport) 
     1655    switch (hdport)
    16561656    {
    16571657        case 500:
    16581658                /* service = sport; */
    16591659        break;
    1660     } 
     1660    }
    16611661#endif
    16621662    Log2(("service : %d\n", service));
Note: See TracChangeset for help on using the changeset viewer.

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