Changeset 74530 in vbox for trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp
- Timestamp:
- Sep 28, 2018 5:45:20 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/linux/NetIf-linux.cpp
r69500 r74530 46 46 * @returns VBox status code. 47 47 * 48 * @param pszName The buffer of IFNAMSIZ+1 length where to put the name. 48 * @param pszName The buffer where to put the name. 49 * @param cbName Size of of the destination buffer. 49 50 */ 50 static int getDefaultIfaceName(char *pszName )51 static int getDefaultIfaceName(char *pszName, size_t cbName) 51 52 { 52 53 FILE *fp = fopen("/proc/net/route", "r"); … … 72 73 { 73 74 fclose(fp); 74 strncpy(pszName, szIfName, 16); 75 pszName[16] = 0; 76 return VINF_SUCCESS; 75 szIfName[sizeof(szIfName) - 1] = '\0'; 76 return RTStrCopy(pszName, cbName, szIfName); 77 77 } 78 78 } … … 220 220 { 221 221 char szDefaultIface[256]; 222 int rc = getDefaultIfaceName(szDefaultIface );222 int rc = getDefaultIfaceName(szDefaultIface, sizeof(szDefaultIface)); 223 223 if (RT_FAILURE(rc)) 224 224 { 225 225 Log(("NetIfList: Failed to find default interface.\n")); 226 szDefaultIface[0] = 0;226 szDefaultIface[0] = '\0'; 227 227 } 228 228 int sock = socket(AF_INET, SOCK_DGRAM, 0);
Note:
See TracChangeset
for help on using the changeset viewer.