VirtualBox

Changeset 23063 in vbox


Ignore:
Timestamp:
Sep 16, 2009 12:03:00 PM (15 years ago)
Author:
vboxsync
Message:

VBoxNetAdpCtl.cpp: a todo + some nitpicking.

File:
1 edited

Legend:

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

    r23059 r23063  
    2525*   Header Files                                                               *
    2626*******************************************************************************/
    27 #include <assert.h>
    2827#include <stdio.h>
    2928#include <stdlib.h>
     
    3736#endif
    3837
    39 /* @todo Error codes must be moved to some header file */
    40 #define ADPCTLERR_NO_CTL_DEV 3
    41 #define ADPCTLERR_IOCTL_FAILED 4
    42 
    43 /* @todo These are duplicates from src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h */
     38/** @todo Error codes must be moved to some header file */
     39#define ADPCTLERR_BAD_NAME         2
     40#define ADPCTLERR_NO_CTL_DEV       3
     41#define ADPCTLERR_IOCTL_FAILED     4
     42
     43/** @todo These are duplicates from src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h */
    4444#define VBOXNETADP_CTL_DEV_NAME    "/dev/vboxnetctl"
    4545#define VBOXNETADP_NAME            "vboxnet"
     
    9595            break;
    9696        case 0: /* Child process. */
     97            /** @todo use execve like below? */
    9798            if (execv(VBOXADPCTL_IFCONFIG_PATH, (char * const*)argv) == -1)
    9899                rc = EXIT_FAILURE;
     
    149150    {
    150151        int cbSkipWS = strspn(szBuf, " \t");
    151 #if 0 /* Don't use this! assert() breaks the mac build. Use IPRT or be a rectangular building thing. */
    152         assert(cbSkipWS < 20);
    153 #endif
    154152        char *pszWord = strtok(szBuf + cbSkipWS, " ");
    155153        /* We are concerned with IPv6 address lines only. */
     
    205203    int iAdapterIndex = -1;
    206204
    207     if (sscanf(pcszNameIn, "vboxnet%d", &iAdapterIndex) != 1
     205    if (   strlen(pcszNameIn) >= VBOXNETADP_MAX_NAME_LEN
     206        || sscanf(pcszNameIn, "vboxnet%d", &iAdapterIndex) != 1
    208207        || iAdapterIndex < 0 || iAdapterIndex > 99 )
    209208    {
    210209        fprintf(stderr, "Setting configuration for %s is not supported.\n", pcszNameIn);
    211         return 2;
     210        return ADPCTLERR_BAD_NAME;
    212211    }
    213212    sprintf(pszNameOut, "vboxnet%d", iAdapterIndex);
     
    215214    {
    216215        fprintf(stderr, "Invalid adapter name %s.\n", pcszNameIn);
    217         return 2;
     216        return ADPCTLERR_BAD_NAME;
    218217    }
    219218
     
    266265                if (rc)
    267266                    return rc;
     267                memset(&Req, '\0', sizeof(Req));
    268268                snprintf(Req.szName, sizeof(Req.szName), "%s", szAdapterName);
    269269                return doIOCtl(VBOXNETADP_CTL_REMOVE, &Req);
     
    273273            if (strcmp("add", argv[1]) == 0)
    274274            {
     275                memset(&Req, '\0', sizeof(Req));
    275276                rc = doIOCtl(VBOXNETADP_CTL_ADD, &Req);
    276277                if (rc == 0)
     
    326327    return rc;
    327328}
     329
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