VirtualBox

Changeset 17805 in vbox for trunk/src/apps/adpctl


Ignore:
Timestamp:
Mar 13, 2009 11:02:48 AM (16 years ago)
Author:
vboxsync
Message:

VBoxNetAdpCtl fix for Darwin build burns.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp

    r17778 r17805  
    2525*   Header Files                                                               *
    2626*******************************************************************************/
    27 #include <string>
    28 #include <list>
    2927#include <assert.h>
    3028#include <stdio.h>
     
    7674}
    7775
     76#define MAX_ADDRESSES 128
     77#define MAX_ADDRLEN   64
     78
    7879static bool removeAddresses(const char *pszAdapterName)
    7980{
    80     static char szCmd[1024], szBuf[1024];
     81    char szCmd[1024], szBuf[1024];
     82    char aszAddresses[MAX_ADDRESSES][MAX_ADDRLEN];
    8183
     84    memset(aszAddresses, 0, sizeof(aszAddresses));
    8285    snprintf(szCmd, sizeof(szCmd), VBOXADPCTL_IFCONFIG_PATH " %s", pszAdapterName);
    8386    FILE *fp = popen(szCmd, "r");
     
    8689        return false;
    8790
    88     std::list<std::string> Addresses;
    89 
    90     while (fgets(szBuf, sizeof(szBuf), fp))
     91    int cAddrs;
     92    for (cAddrs = 0; cAddrs < MAX_ADDRESSES && fgets(szBuf, sizeof(szBuf), fp);)
    9193    {
    9294        int cbSkipWS = strspn(szBuf, " \t");
     
    100102        if (!pszWord || !strncmp(pszWord, "fe80", 4))
    101103            continue;
    102         Addresses.push_back(std::string(pszWord));
     104        strncpy(aszAddresses[cAddrs++], pszWord, MAX_ADDRLEN-1);
    103105    }
    104106    pclose(fp);
    105107
    106     std::list<std::string>::const_iterator it;
    107     for (it = Addresses.begin(); it != Addresses.end(); it++)
     108    for (int i = 0; i < cAddrs; i++)
    108109    {
    109         if (executeIfconfig(pszAdapterName, "inet6", it->c_str(), "remove") != EXIT_SUCCESS)
     110        if (executeIfconfig(pszAdapterName, "inet6", aszAddresses[i], "remove") != EXIT_SUCCESS)
    110111            return false;
    111112    }
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