VirtualBox

Changeset 103427 in vbox for trunk/src


Ignore:
Timestamp:
Feb 19, 2024 11:46:34 AM (12 months ago)
Author:
vboxsync
Message:

Main/xpcom/server_module.cpp: Use RTPathAppend instead of RTStrCat and drop the leading slash from g_szVBoxSVC_exe. We can also dispense with the buffer size checking when using RTStrCpy + RTPathAppend. Hardened Solaris should use VBOX_PATH_APP_PRIVATE. bugref:3409

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/xpcom/server_module.cpp

    r103285 r103427  
    7575
    7676/** Name of the server executable. */
    77 const char g_szVBoxSVC_exe[] = RTPATH_SLASH_STR "VBoxSVC" HOSTSUFF_EXE;
     77static const char g_szVBoxSVC_exe[] = "VBoxSVC" HOSTSUFF_EXE;
    7878
    7979enum
     
    204204
    205205                    LogFlowFunc(("component directory = \"%s\"\n", path.get()));
    206                     AssertBreakStmt(path.Length() + strlen(g_szVBoxSVC_exe) < RTPATH_MAX,
    207                                     rc = NS_ERROR_FAILURE);
    208206
    209207#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_HARDENING)
    210                     char achKernArch[128];
    211                     int cbKernArch = sysinfo(SI_ARCHITECTURE_K, achKernArch, sizeof(achKernArch));
    212                     if (cbKernArch > 0)
    213                     {
    214                         sprintf(g_szVBoxSVCPath, "/opt/VirtualBox/%s%s", achKernArch, g_szVBoxSVC_exe);
    215                         g_fIsVBoxSVCPathSet = true;
    216                     }
    217                     else
    218                         rc = NS_ERROR_UNEXPECTED;
     208                    char szKernArch[128];
     209                    int  cbKernArch = sysinfo(SI_ARCHITECTURE_K, szKernArch, sizeof(szKernArch));
     210                    AssertBreakStmt(cbKernArch > 0, rc = NS_ERROR_UNEXPECTED);
     211# ifdef VBOX_PATH_APP_PRIVATE
     212                    sprintf(g_szVBoxSVCPath, VBOX_PATH_APP_PRIVATE "/%s/%s", szKernArch, g_szVBoxSVC_exe);
     213# else
     214                    sprintf(g_szVBoxSVCPath, "/opt/VirtualBox/%s/%s", szKernArch, g_szVBoxSVC_exe);
     215# endif
     216                    g_fIsVBoxSVCPathSet = true;
    219217#else
    220218                    int vrc = RTStrCopy(g_szVBoxSVCPath, sizeof(g_szVBoxSVCPath), path.get());
    221219                    AssertRCBreakStmt(vrc, rc = NS_ERROR_FAILURE);
    222                     RTPathStripFilename(g_szVBoxSVCPath);
    223                     vrc = RTStrCat(g_szVBoxSVCPath, sizeof(g_szVBoxSVCPath), g_szVBoxSVC_exe);
     220
     221                    RTPathStripFilename(g_szVBoxSVCPath); /* ".." to the parent directory */
     222
     223                    vrc = RTPathAppend(g_szVBoxSVCPath, sizeof(g_szVBoxSVCPath), g_szVBoxSVC_exe);
    224224                    AssertRCBreakStmt(vrc, rc = NS_ERROR_FAILURE);
    225 
    226225                    g_fIsVBoxSVCPathSet = true;
    227226#endif
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