Changeset 23063 in vbox for trunk/src/apps/adpctl
- Timestamp:
- Sep 16, 2009 12:03:00 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/apps/adpctl/VBoxNetAdpCtl.cpp
r23059 r23063 25 25 * Header Files * 26 26 *******************************************************************************/ 27 #include <assert.h>28 27 #include <stdio.h> 29 28 #include <stdlib.h> … … 37 36 #endif 38 37 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 */ 44 44 #define VBOXNETADP_CTL_DEV_NAME "/dev/vboxnetctl" 45 45 #define VBOXNETADP_NAME "vboxnet" … … 95 95 break; 96 96 case 0: /* Child process. */ 97 /** @todo use execve like below? */ 97 98 if (execv(VBOXADPCTL_IFCONFIG_PATH, (char * const*)argv) == -1) 98 99 rc = EXIT_FAILURE; … … 149 150 { 150 151 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 #endif154 152 char *pszWord = strtok(szBuf + cbSkipWS, " "); 155 153 /* We are concerned with IPv6 address lines only. */ … … 205 203 int iAdapterIndex = -1; 206 204 207 if (sscanf(pcszNameIn, "vboxnet%d", &iAdapterIndex) != 1 205 if ( strlen(pcszNameIn) >= VBOXNETADP_MAX_NAME_LEN 206 || sscanf(pcszNameIn, "vboxnet%d", &iAdapterIndex) != 1 208 207 || iAdapterIndex < 0 || iAdapterIndex > 99 ) 209 208 { 210 209 fprintf(stderr, "Setting configuration for %s is not supported.\n", pcszNameIn); 211 return 2;210 return ADPCTLERR_BAD_NAME; 212 211 } 213 212 sprintf(pszNameOut, "vboxnet%d", iAdapterIndex); … … 215 214 { 216 215 fprintf(stderr, "Invalid adapter name %s.\n", pcszNameIn); 217 return 2;216 return ADPCTLERR_BAD_NAME; 218 217 } 219 218 … … 266 265 if (rc) 267 266 return rc; 267 memset(&Req, '\0', sizeof(Req)); 268 268 snprintf(Req.szName, sizeof(Req.szName), "%s", szAdapterName); 269 269 return doIOCtl(VBOXNETADP_CTL_REMOVE, &Req); … … 273 273 if (strcmp("add", argv[1]) == 0) 274 274 { 275 memset(&Req, '\0', sizeof(Req)); 275 276 rc = doIOCtl(VBOXNETADP_CTL_ADD, &Req); 276 277 if (rc == 0) … … 326 327 return rc; 327 328 } 329
Note:
See TracChangeset
for help on using the changeset viewer.