VirtualBox

Changeset 103260 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Feb 7, 2024 4:56:08 PM (12 months ago)
Author:
vboxsync
Message:

Got rid of a lot of deprecated strcpy / strcat calls; now using the IPRT pendants (found by Parfait). bugref:3409

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

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

    r98288 r103260  
    531531        return;
    532532    }
    533     strcat(szVolInfo, "/" VBOXVOLINFO_NAME " ");
    534     strcat(szVolInfo, pcszVolume);
     533    vrc = RTStrCat(szVolInfo, sizeof(szVolInfo), "/" VBOXVOLINFO_NAME " ");
     534    AssertRCReturnVoid(vrc);
     535    vrc = RTStrCat(szVolInfo, sizeof(szVolInfo), pcszVolume);
     536    AssertRCReturnVoid(vrc);
    535537
    536538    FILE *fp = popen(szVolInfo, "r");
  • trunk/src/VBox/Main/src-server/xpcom/server_module.cpp

    r102206 r103260  
    7575
    7676/** Name of the server executable. */
    77 const char VBoxSVC_exe[] = RTPATH_SLASH_STR "VBoxSVC" HOSTSUFF_EXE;
     77const char g_szVBoxSVC_exe[] = RTPATH_SLASH_STR "VBoxSVC" HOSTSUFF_EXE;
    7878
    7979enum
     
    8888 *  Full path to the VBoxSVC executable.
    8989 */
    90 static char VBoxSVCPath[RTPATH_MAX];
    91 static bool IsVBoxSVCPathSet = false;
     90static char g_szVBoxSVCPath[RTPATH_MAX];
     91static bool g_fIsVBoxSVCPathSet = false;
    9292
    9393/*
     
    116116        const char *apszArgs[] =
    117117        {
    118             VBoxSVCPath,
     118            g_szVBoxSVCPath,
    119119            "--auto-shutdown",
    120120            "--inherit-startup-pipe",
     
    132132        hStdNil.u.hFile = NIL_RTFILE;
    133133
    134         vrc = RTProcCreateEx(VBoxSVCPath, apszArgs, RTENV_DEFAULT,
     134        vrc = RTProcCreateEx(g_szVBoxSVCPath, apszArgs, RTENV_DEFAULT,
    135135                             RTPROC_FLAGS_DETACHED, &hStdNil, &hStdNil, &hStdNil,
    136136                             NULL /* pszAsUser */, NULL /* pszPassword */, NULL /* pExtraData */,
     
    187187        }
    188188
    189         if (!IsVBoxSVCPathSet)
     189        if (!g_fIsVBoxSVCPathSet)
    190190        {
    191191            /* Get the directory containing XPCOM components -- the VBoxSVC
     
    204204
    205205                    LogFlowFunc(("component directory = \"%s\"\n", path.get()));
    206                     AssertBreakStmt(path.Length() + strlen(VBoxSVC_exe) < RTPATH_MAX,
     206                    AssertBreakStmt(path.Length() + strlen(g_szVBoxSVC_exe) < RTPATH_MAX,
    207207                                    rc = NS_ERROR_FAILURE);
    208208
     
    212212                    if (cbKernArch > 0)
    213213                    {
    214                         sprintf(VBoxSVCPath, "/opt/VirtualBox/%s%s", achKernArch, VBoxSVC_exe);
    215                         IsVBoxSVCPathSet = true;
     214                        sprintf(g_szVBoxSVCPath, "/opt/VirtualBox/%s%s", achKernArch, g_szVBoxSVC_exe);
     215                        g_fIsVBoxSVCPathSet = true;
    216216                    }
    217217                    else
    218218                        rc = NS_ERROR_UNEXPECTED;
    219219#else
    220                     strcpy(VBoxSVCPath, path.get());
    221                     RTPathStripFilename(VBoxSVCPath);
    222                     strcat(VBoxSVCPath, VBoxSVC_exe);
    223 
    224                     IsVBoxSVCPathSet = true;
     220                    int vrc = RTStrCopy(g_szVBoxSVCPath, sizeof(g_szVBoxSVCPath), path.get());
     221                    AssertRCBreakStmt(vrc, rc = NS_ERROR_FAILURE);
     222                    RTPathStripFilename(g_szVBoxSVCPath);
     223                    vrc = RTStrCat(g_szVBoxSVCPath, sizeof(g_szVBoxSVCPath), g_szVBoxSVC_exe);
     224                    AssertRCBreakStmt(vrc, rc = NS_ERROR_FAILURE);
     225
     226                    g_fIsVBoxSVCPathSet = true;
    225227#endif
    226228                }
     
    247249            if (NS_FAILED(rc))
    248250            {
    249                 LogFlowFunc(("Starting server \"%s\"...\n", VBoxSVCPath));
     251                LogFlowFunc(("Starting server \"%s\"...\n", g_szVBoxSVCPath));
    250252
    251253                startedOnce = true;
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