VirtualBox

Ignore:
Timestamp:
Sep 28, 2018 5:45:20 PM (6 years ago)
Author:
vboxsync
Message:

Main,Devices: Compile fixes (gcc 8.2.0-7).

File:
1 edited

Legend:

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

    r69500 r74530  
    4646 * @returns VBox status code.
    4747 *
    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.
    4950 */
    50 static int getDefaultIfaceName(char *pszName)
     51static int getDefaultIfaceName(char *pszName, size_t cbName)
    5152{
    5253    FILE *fp = fopen("/proc/net/route", "r");
     
    7273            {
    7374                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);
    7777            }
    7878        }
     
    220220{
    221221    char szDefaultIface[256];
    222     int rc = getDefaultIfaceName(szDefaultIface);
     222    int rc = getDefaultIfaceName(szDefaultIface, sizeof(szDefaultIface));
    223223    if (RT_FAILURE(rc))
    224224    {
    225225        Log(("NetIfList: Failed to find default interface.\n"));
    226         szDefaultIface[0] = 0;
     226        szDefaultIface[0] = '\0';
    227227    }
    228228    int sock = socket(AF_INET, SOCK_DGRAM, 0);
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