VirtualBox

Changeset 23136 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 18, 2009 2:22:28 PM (15 years ago)
Author:
vboxsync
Message:

NetIf-darwin.cpp: Corrected search search on BSD name in the list returned by DarwinGetEthernetControllers: Use the right length, sdl_nlen instead of sdl_len. And, sdl_data isn't null terminated but szBSDName is, so we have to check that the latter is terminated where we stopped comparing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/darwin/NetIf-darwin.cpp

    r23103 r23136  
    171171
    172172        pAddresses[i] = sa;
    173        
     173
    174174        ADVANCE(cp, sa);
    175175    }
     
    180180    struct sockaddr *addresses[RTAX_MAX];
    181181
    182     extractAddresses(iAddrMask, cp, cplim, addresses); 
     182    extractAddresses(iAddrMask, cp, cplim, addresses);
    183183    switch (addresses[RTAX_IFA]->sa_family)
    184184    {
     
    213213    int aiMib[6];
    214214    struct sockaddr *addresses[RTAX_MAX];
    215    
     215
    216216    aiMib[0] = CTL_NET;
    217217    aiMib[1] = PF_ROUTE;
     
    335335
    336336        size_t cbNameLen = pSdl->sdl_nlen + 1;
     337        Assert(pSdl->sdl_nlen < sizeof(pNIC->szBSDName));
    337338        for (pNIC = pEtherNICs; pNIC; pNIC = pNIC->pNext)
    338             if (!strncmp(pSdl->sdl_data, pNIC->szBSDName, pSdl->sdl_len))
     339            if (   !strncmp(pSdl->sdl_data, pNIC->szBSDName, pSdl->sdl_nlen)
     340                && pNIC->szBSDName[pSdl->sdl_nlen] == '\0')
    339341            {
    340342                cbNameLen = strlen(pEtherNICs->szName) + 1;
     
    349351        memcpy(pNew->MACAddress.au8, LLADDR(pSdl), sizeof(pNew->MACAddress.au8));
    350352        pNew->enmMediumType = NETIF_T_ETHERNET;
    351         Assert(sizeof(pNew->szShortName) >= cbNameLen);
    352         memcpy(pNew->szShortName, pSdl->sdl_data, pSdl->sdl_nlen);
     353        Assert(sizeof(pNew->szShortName) > pSdl->sdl_nlen);
     354        memcpy(pNew->szShortName, pSdl->sdl_data, RT_MIN(pSdl->sdl_nlen, sizeof(pNew->szShortName) - 1));
     355
    353356        /*
    354357         * If we found the adapter in the list returned by
     
    433436    char *pBuf, *pNext;
    434437    int aiMib[6];
    435    
     438
    436439    aiMib[0] = CTL_NET;
    437440    aiMib[1] = PF_ROUTE;
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