VirtualBox

Changeset 84147 in vbox


Ignore:
Timestamp:
May 5, 2020 3:34:38 PM (4 years ago)
Author:
vboxsync
Message:

Guest Control/VBoxService: Implemented heap data allocation for VBOXSERVICECTRLSESSIONSTARTUPINFO + VBOXSERVICECTRLPROCSTARTUPINFO. bugref:9320

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/GuestControl.h

    r83651 r84147  
    135135/** @} */
    136136
    137 /** @name Defines for guest process array lengths.
     137/** @name Defines for maximum guest process buffer lengths.
    138138 * @{
    139139 */
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r83974 r84147  
    395395     * Retrieve the message parameters.
    396396     */
    397     VBOXSERVICECTRLSESSIONSTARTUPINFO ssInfo = { 0 };
    398     int rc = VbglR3GuestCtrlSessionGetOpen(pHostCtx,
    399                                            &ssInfo.uProtocol,
    400                                            ssInfo.szUser,     sizeof(ssInfo.szUser),
    401                                            ssInfo.szPassword, sizeof(ssInfo.szPassword),
    402                                            ssInfo.szDomain,   sizeof(ssInfo.szDomain),
    403                                            &ssInfo.fFlags,    &ssInfo.uSessionID);
     397    VBOXSERVICECTRLSESSIONSTARTUPINFO startupInfo;
     398    int rc = VgsvcGstCtrlSessionStartupInfoInit(&startupInfo);
     399    if (RT_FAILURE(rc))
     400        return rc;
     401
     402    rc = VbglR3GuestCtrlSessionGetOpen(pHostCtx,
     403                                       &startupInfo.uProtocol,
     404                                       startupInfo.pszUser,     startupInfo.cbUser,
     405                                       startupInfo.pszPassword, startupInfo.cbPassword,
     406                                       startupInfo.pszDomain,   startupInfo.cbDomain,
     407                                       &startupInfo.fFlags,    &startupInfo.uSessionID);
    404408    if (RT_SUCCESS(rc))
    405409    {
     
    407411         * Flat out refuse to work with protocol v1 hosts.
    408412         */
    409         if (ssInfo.uProtocol == 2)
    410         {
    411             pHostCtx->uProtocol = ssInfo.uProtocol;
     413        if (startupInfo.uProtocol == 2)
     414        {
     415            pHostCtx->uProtocol = startupInfo.uProtocol;
    412416            VGSvcVerbose(3, "Client ID=%RU32 now is using protocol %RU32\n", pHostCtx->uClientID, pHostCtx->uProtocol);
    413417
    414418/** @todo Someone explain why this code isn't in this file too?  v1 support? */
    415             rc = VGSvcGstCtrlSessionThreadCreate(&g_lstControlSessionThreads, &ssInfo, NULL /* ppSessionThread */);
     419            rc = VGSvcGstCtrlSessionThreadCreate(&g_lstControlSessionThreads, &startupInfo, NULL /* ppSessionThread */);
    416420            /* Report failures to the host (successes are taken care of by the session thread). */
    417421        }
    418422        else
    419423        {
    420             VGSvcError("The host wants to use protocol v%u, we only support v2!\n", ssInfo.uProtocol);
     424            VGSvcError("The host wants to use protocol v%u, we only support v2!\n", startupInfo.uProtocol);
    421425            rc = VERR_VERSION_MISMATCH;
    422426        }
     
    433437        VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX);
    434438    }
     439
     440    VgsvcGstCtrlSessionStartupInfoDestroy(&startupInfo);
     441
    435442    VGSvcVerbose(3, "Opening a new guest session returned rc=%Rrc\n", rc);
    436443    return rc;
     
    452459        RTListForEach(&g_lstControlSessionThreads, pThread, VBOXSERVICECTRLSESSIONTHREAD, Node)
    453460        {
    454             if (pThread->StartupInfo.uSessionID == idSession)
     461            if (   pThread->pStartupInfo
     462                && pThread->pStartupInfo->uSessionID == idSession)
    455463            {
    456464                rc = VGSvcGstCtrlSessionThreadDestroy(pThread, fFlags);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h

    r83409 r84147  
    8181    uint32_t                        uSessionID;
    8282    /** User name (account) to start the guest session under. */
    83     char                            szUser[GUESTPROCESS_MAX_USER_LEN];
     83    char                           *pszUser;
     84    /** Size (in bytes) of allocated pszUser. */
     85    uint32_t                        cbUser;
    8486    /** Password of specified user name (account). */
    85     char                            szPassword[GUESTPROCESS_MAX_PASSWORD_LEN];
     87    char                           *pszPassword;
     88    /** Size (in bytes) of allocated pszPassword. */
     89    uint32_t                        cbPassword;
    8690    /** Domain of the user account. */
    87     char                            szDomain[GUESTPROCESS_MAX_DOMAIN_LEN];
     91    char                           *pszDomain;
     92    /** Size (in bytes) of allocated pszDomain. */
     93    uint32_t                        cbDomain;
    8894    /** Session creation flags.
    8995     *  @sa VBOXSERVICECTRLSESSIONSTARTUPFLAG_* flags. */
     
    104110    RTLISTNODE                      Node;
    105111    /** The sessions's startup info. */
    106     VBOXSERVICECTRLSESSIONSTARTUPINFO StartupInfo;
     112    PVBOXSERVICECTRLSESSIONSTARTUPINFO
     113                                    pStartupInfo;
    107114    /** Critical section for thread-safe use. */
    108115    RTCRITSECT                      CritSect;
     
    207214typedef struct VBOXSERVICECTRLPROCSTARTUPINFO
    208215{
    209     /** Full qualified path of process to start (without arguments). */
    210     char szCmd[GUESTPROCESS_MAX_CMD_LEN];
     216    /** Full qualified path of process to start (without arguments).
     217     *  Note: This is *not* argv[0]! */
     218    char *pszCmd;
     219    /** Size (in bytes) of allocated pszCmd. */
     220    uint32_t cbCmd;
    211221    /** Process execution flags. @sa */
    212     uint32_t uFlags;
     222    uint32_t fFlags;
    213223    /** Command line arguments. */
    214     char szArgs[GUESTPROCESS_MAX_ARGS_LEN];
     224    char *pszArgs;
     225    /** Size (in bytes) of allocated pszArgs. */
     226    uint32_t cbArgs;
    215227    /** Number of arguments specified in pszArgs. */
    216     uint32_t uNumArgs;
     228    uint32_t cArgs;
    217229    /** String of environment variables ("FOO=BAR") to pass to the process
    218230      * to start. */
    219     char szEnv[GUESTPROCESS_MAX_ENV_LEN];
     231    char *pszEnv;
    220232    /** Size (in bytes) of environment variables block. */
    221233    uint32_t cbEnv;
    222234    /** Number of environment variables specified in pszEnv. */
    223     uint32_t uNumEnvVars;
     235    uint32_t cEnvVars;
    224236    /** User name (account) to start the process under. */
    225     char szUser[GUESTPROCESS_MAX_USER_LEN];
     237    char *pszUser;
     238    /** Size (in bytes) of allocated pszUser. */
     239    uint32_t cbUser;
    226240    /** Password of specified user name (account). */
    227     char szPassword[GUESTPROCESS_MAX_PASSWORD_LEN];
     241    char *pszPassword;
     242    /** Size (in bytes) of allocated pszPassword. */
     243    uint32_t cbPassword;
    228244    /** Domain to be used for authenticating the specified user name (account). */
    229     char szDomain[GUESTPROCESS_MAX_DOMAIN_LEN];
     245    char *pszDomain;
     246    /** Size (in bytes) of allocated pszDomain. */
     247    uint32_t cbDomain;
    230248    /** Time limit (in ms) of the process' life time. */
    231249    uint32_t uTimeLimitMS;
     
    269287    RTCRITSECT                      CritSect;
    270288    /** Process startup information. */
    271     VBOXSERVICECTRLPROCSTARTUPINFO
    272                                     StartupInfo;
     289    PVBOXSERVICECTRLPROCSTARTUPINFO
     290                                    pStartupInfo;
    273291    /** The process' PID assigned by the guest OS. */
    274292    uint32_t                        uPID;
     
    318336/** @name Per-session functions.
    319337 * @{ */
     338extern int                      VgsvcGstCtrlSessionStartupInfoInit(PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfo);
     339extern void                     VgsvcGstCtrlSessionStartupInfoDestroy(PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfo);
     340
    320341extern PVBOXSERVICECTRLPROCESS  VGSvcGstCtrlSessionRetainProcess(PVBOXSERVICECTRLSESSION pSession, uint32_t uPID);
    321342extern int                      VGSvcGstCtrlSessionClose(PVBOXSERVICECTRLSESSION pSession);
     
    330351/** @name Per-guest process functions.
    331352 * @{ */
     353extern int                      VgsvcGstCtrlProcessStartupInfoInit(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo);
     354extern int                      VgsvcGstCtrlProcessStartupInfoInitEx(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo, size_t cbEnv, size_t cbArgs);
     355extern void                     VgsvcGstCtrlProcessStartupInfoDestroy(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo);
     356extern void                     VgsvcGstCtrlProcessStartupInfoFree(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo);
     357
    332358extern int                      VGSvcGstCtrlProcessFree(PVBOXSERVICECTRLPROCESS pProcess);
    333359extern int                      VGSvcGstCtrlProcessHandleInput(PVBOXSERVICECTRLPROCESS pProcess, PVBGLR3GUESTCTRLCMDCTX pHostCtx, bool fPendingClose, void *pvBuf, uint32_t cbBuf);
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r84140 r84147  
    6262
    6363/**
     64 * Initializes a process startup info, extended version.
     65 *
     66 * @returns VBox status code.
     67 * @param   pStartupInfo        Process startup info to initializes.
     68 * @param   cbArgs              Size (in bytes) to use for the arguments buffer.
     69 * @param   cbEnv               Size (in bytes) to use for the environment buffer.
     70 */
     71int VgsvcGstCtrlProcessStartupInfoInitEx(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo,
     72                                         size_t cbArgs, size_t cbEnv)
     73{
     74    AssertPtrReturn(pStartupInfo, VERR_INVALID_POINTER);
     75    AssertReturn(cbArgs,          VERR_INVALID_PARAMETER);
     76    AssertReturn(cbEnv,           VERR_INVALID_PARAMETER);
     77
     78    RT_BZERO(pStartupInfo, sizeof(VBOXSERVICECTRLPROCSTARTUPINFO));
     79
     80#define ALLOC_STR(a_Str, a_cb) \
     81    if ((a_cb) > 0) \
     82    { \
     83        pStartupInfo->psz##a_Str = RTStrAlloc(a_cb); \
     84        AssertPtrBreak(pStartupInfo->psz##a_Str); \
     85        pStartupInfo->cb##a_Str  = a_cb; \
     86    }
     87
     88    do
     89    {
     90        ALLOC_STR(Cmd,      sizeof(char) * GUESTPROCESS_MAX_CMD_LEN);
     91        ALLOC_STR(Args,     cbArgs);
     92        ALLOC_STR(Env,      cbEnv);
     93        ALLOC_STR(User,     sizeof(char) * GUESTPROCESS_MAX_USER_LEN);
     94        ALLOC_STR(Password, sizeof(char) * GUESTPROCESS_MAX_PASSWORD_LEN);
     95        ALLOC_STR(Domain,   sizeof(char) * GUESTPROCESS_MAX_DOMAIN_LEN);
     96
     97        return VINF_SUCCESS;
     98
     99    } while (0);
     100
     101#undef ALLOC_STR
     102
     103    VgsvcGstCtrlProcessStartupInfoDestroy(pStartupInfo);
     104    return VERR_NO_MEMORY;
     105}
     106
     107/**
     108 * Initializes a process startup info with default values.
     109 *
     110 * @param   pStartupInfo        Process startup info to initializes.
     111 */
     112int VgsvcGstCtrlProcessStartupInfoInit(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo)
     113{
     114    return VgsvcGstCtrlProcessStartupInfoInitEx(pStartupInfo,
     115                                                GUESTPROCESS_MAX_ARGS_LEN, GUESTPROCESS_MAX_ENV_LEN);
     116}
     117
     118/**
     119 * Destroys a process startup info.
     120 *
     121 * @param   pStartupInfo        Process startup info to destroy.
     122 */
     123void VgsvcGstCtrlProcessStartupInfoDestroy(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo)
     124{
     125    if (!pStartupInfo)
     126        return;
     127
     128    RTStrFree(pStartupInfo->pszCmd);
     129    RTStrFree(pStartupInfo->pszArgs);
     130    RTStrFree(pStartupInfo->pszEnv);
     131    RTStrFree(pStartupInfo->pszUser);
     132    RTStrFree(pStartupInfo->pszPassword);
     133    RTStrFree(pStartupInfo->pszDomain);
     134
     135    RT_BZERO(pStartupInfo, sizeof(VBOXSERVICECTRLPROCSTARTUPINFO));
     136}
     137
     138/**
     139 * Free's a process startup info.
     140 *
     141 * @param   pStartupInfo        Process startup info to free.
     142 *                              The pointer will not be valid anymore after return.
     143 */
     144void VgsvcGstCtrlProcessStartupInfoFree(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo)
     145{
     146    if (!pStartupInfo)
     147        return;
     148
     149    VgsvcGstCtrlProcessStartupInfoDestroy(pStartupInfo);
     150
     151    RTMemFree(pStartupInfo);
     152    pStartupInfo = NULL;
     153}
     154
     155/**
     156 * Duplicates a process startup info.
     157 *
     158 * @returns Duplicated process startup info on success, or NULL on error.
     159 * @param   pStartupInfo        Process startup info to duplicate.
     160 */
     161static PVBOXSERVICECTRLPROCSTARTUPINFO vgsvcGstCtrlProcessStartupInfoDup(PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfo)
     162{
     163    AssertPtrReturn(pStartupInfo, NULL);
     164
     165    PVBOXSERVICECTRLPROCSTARTUPINFO pStartupInfoDup = (PVBOXSERVICECTRLPROCSTARTUPINFO)
     166                                                            RTMemDup(pStartupInfo, sizeof(VBOXSERVICECTRLPROCSTARTUPINFO));
     167    if (pStartupInfoDup)
     168    {
     169        do
     170        {
     171            pStartupInfoDup->pszCmd      = NULL;
     172            pStartupInfoDup->pszArgs     = NULL;
     173            pStartupInfoDup->pszEnv      = NULL;
     174            pStartupInfoDup->pszUser     = NULL;
     175            pStartupInfoDup->pszPassword = NULL;
     176            pStartupInfoDup->pszDomain   = NULL;
     177
     178#define DUP_STR(a_Str) \
     179    if (pStartupInfo->cb##a_Str) \
     180    { \
     181        pStartupInfoDup->psz##a_Str = (char *)RTMemDup(pStartupInfo->psz##a_Str, pStartupInfo->cb##a_Str); \
     182        AssertPtrBreak(pStartupInfoDup->psz##a_Str); \
     183        pStartupInfoDup->cb##a_Str  = pStartupInfo->cb##a_Str; \
     184    }
     185
     186            DUP_STR(Cmd);
     187            DUP_STR(Args);
     188            DUP_STR(Env);
     189            DUP_STR(User);
     190            DUP_STR(Password);
     191            DUP_STR(Domain);
     192
     193#undef DUP_STR
     194
     195            return pStartupInfoDup;
     196
     197        } while (0); /* To use break macros above. */
     198
     199        VgsvcGstCtrlProcessStartupInfoFree(pStartupInfoDup);
     200    }
     201
     202    return NULL;
     203}
     204
     205/**
    64206 * Initialies the passed in thread data structure with the parameters given.
    65207 *
     
    117259    AssertReleaseRC(rc);
    118260
    119     /* Copy over startup info. */
    120     memcpy(&pProcess->StartupInfo, pStartupInfo, sizeof(VBOXSERVICECTRLPROCSTARTUPINFO));
     261    /* Duplicate startup info. */
     262    pProcess->pStartupInfo = vgsvcGstCtrlProcessStartupInfoDup(pStartupInfo);
     263    AssertPtrReturn(pProcess->pStartupInfo, VERR_NO_MEMORY);
    121264
    122265    /* Adjust timeout value. */
    123     if (   pProcess->StartupInfo.uTimeLimitMS == UINT32_MAX
    124         || pProcess->StartupInfo.uTimeLimitMS == 0)
    125         pProcess->StartupInfo.uTimeLimitMS = RT_INDEFINITE_WAIT;
     266    if (   pProcess->pStartupInfo->uTimeLimitMS == UINT32_MAX
     267        || pProcess->pStartupInfo->uTimeLimitMS == 0)
     268        pProcess->pStartupInfo->uTimeLimitMS = RT_INDEFINITE_WAIT;
    126269
    127270    if (RT_FAILURE(rc)) /* Clean up on failure. */
     
    151294        AssertReturn(pProcess->fStopped, VERR_WRONG_ORDER);
    152295        AssertReturn(pProcess->fShutdown, VERR_WRONG_ORDER);
     296
     297        VgsvcGstCtrlProcessStartupInfoFree(pProcess->pStartupInfo);
     298        pProcess->pStartupInfo = NULL;
    153299
    154300        /*
     
    527673     */
    528674    VGSvcVerbose(2, "[PID %RU32]: Process '%s' started, CID=%u, User=%s, cMsTimeout=%RU32\n",
    529                        pProcess->uPID, pProcess->StartupInfo.szCmd, pProcess->uContextID,
    530                        pProcess->StartupInfo.szUser, pProcess->StartupInfo.uTimeLimitMS);
     675                       pProcess->uPID, pProcess->pStartupInfo->pszCmd, pProcess->uContextID,
     676                       pProcess->pStartupInfo->pszUser, pProcess->pStartupInfo->uTimeLimitMS);
    531677    VBGLR3GUESTCTRLCMDCTX ctxStart = { g_idControlSvcClient, pProcess->uContextID };
    532678    rc = VbglR3GuestCtrlProcCbStatus(&ctxStart,
     
    670816         */
    671817        uint32_t cMilliesLeft = RT_INDEFINITE_WAIT;
    672         if (   pProcess->StartupInfo.uTimeLimitMS != RT_INDEFINITE_WAIT
    673             && pProcess->StartupInfo.uTimeLimitMS != 0)
     818        if (   pProcess->pStartupInfo->uTimeLimitMS != RT_INDEFINITE_WAIT
     819            && pProcess->pStartupInfo->uTimeLimitMS != 0)
    674820        {
    675821            uint64_t u64Now = RTTimeMilliTS();
    676822            uint64_t cMsElapsed = u64Now - uMsStart;
    677             if (cMsElapsed >= pProcess->StartupInfo.uTimeLimitMS)
     823            if (cMsElapsed >= pProcess->pStartupInfo->uTimeLimitMS)
    678824            {
    679825                fProcessTimedOut = true;
     
    685831
    686832                    VGSvcVerbose(3, "[PID %RU32]: Timed out (%RU64ms elapsed > %RU32ms timeout), killing ...\n",
    687                                  pProcess->uPID, cMsElapsed, pProcess->StartupInfo.uTimeLimitMS);
     833                                 pProcess->uPID, cMsElapsed, pProcess->pStartupInfo->uTimeLimitMS);
    688834
    689835                    rc2 = RTProcTerminate(pProcess->hProcess);
     
    696842            }
    697843            else
    698                 cMilliesLeft = pProcess->StartupInfo.uTimeLimitMS - (uint32_t)cMsElapsed;
     844                cMilliesLeft = pProcess->pStartupInfo->uTimeLimitMS - (uint32_t)cMsElapsed;
    699845        }
    700846
     
    816962            VGSvcVerbose(3, "[PID %RU32]: Got terminated because system/service is about to shutdown\n", pProcess->uPID);
    817963            uStatus = PROC_STS_DWN; /* Service is stopping, process was killed. */
    818             fFlags  = pProcess->StartupInfo.uFlags; /* Return handed-in execution flags back to the host. */
     964            fFlags  = pProcess->pStartupInfo->fFlags; /* Return handed-in execution flags back to the host. */
    819965        }
    820966        else if (fProcessAlive)
     
    15071653{
    15081654    AssertPtrReturn(pProcess, VERR_INVALID_POINTER);
    1509     VGSvcVerbose(3, "Thread of process pThread=0x%p = '%s' started\n", pProcess, pProcess->StartupInfo.szCmd);
    1510 
    1511     VGSvcVerbose(3, "Guest process '%s', flags=0x%x\n", pProcess->StartupInfo.szCmd, pProcess->StartupInfo.uFlags);
     1655    VGSvcVerbose(3, "Thread of process pThread=0x%p = '%s' started\n", pProcess, pProcess->pStartupInfo->pszCmd);
     1656
     1657    VGSvcVerbose(3, "Guest process '%s', flags=0x%x\n", pProcess->pStartupInfo->pszCmd, pProcess->pStartupInfo->fFlags);
    15121658
    15131659    int rc = VGSvcGstCtrlSessionProcessAdd(pProcess->pSession, pProcess);
     
    15151661    {
    15161662        VGSvcError("Error while adding guest process '%s' (%p) to session process list, rc=%Rrc\n",
    1517                    pProcess->StartupInfo.szCmd, pProcess, rc);
     1663                   pProcess->pStartupInfo->pszCmd, pProcess, rc);
    15181664        RTThreadUserSignal(RTThreadSelf());
    15191665        return rc;
     
    15261672     */
    15271673    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: fHostFeatures0       = %#x\n",     g_fControlHostFeatures0);
    1528     VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.szCmd    = '%s'\n",    pProcess->StartupInfo.szCmd);
    1529     VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.uNumArgs = '%RU32'\n", pProcess->StartupInfo.uNumArgs);
     1674    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.szCmd    = '%s'\n",    pProcess->pStartupInfo->pszCmd);
     1675    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.uNumArgs = '%RU32'\n", pProcess->pStartupInfo->cArgs);
    15301676#ifdef DEBUG /* Never log this stuff in release mode! */
    1531     VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.szArgs   = '%s'\n",    pProcess->StartupInfo.szArgs);
     1677    VGSvcVerbose(3, "vgsvcGstCtrlProcessProcessWorker: StartupInfo.szArgs   = '%s'\n",    pProcess->pStartupInfo->pszArgs);
    15321678#endif
    15331679
     
    15351681    int cArgs = 0; /* Initialize in case of RTGetOptArgvFromString() is failing ... */
    15361682    rc = RTGetOptArgvFromString(&papszArgs, &cArgs,
    1537                                 pProcess->StartupInfo.uNumArgs > 0 ? pProcess->StartupInfo.szArgs : "",
     1683                                pProcess->pStartupInfo->cArgs > 0 ? pProcess->pStartupInfo->pszArgs : "",
    15381684                                RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL);
    15391685
     
    15481694    /* Did we get the same result?
    15491695     * Take into account that we might not have supplied a (correct) argv[0] from the host. */
    1550     AssertMsg((int)pProcess->StartupInfo.uNumArgs == cArgsToCheck,
     1696    AssertMsg((int)pProcess->pStartupInfo->cArgs == cArgsToCheck,
    15511697              ("rc=%Rrc, StartupInfo.uNumArgs=%RU32 != cArgsToCheck=%d, cArgs=%d, fHostFeatures0=%#x\n",
    1552                rc, pProcess->StartupInfo.uNumArgs, cArgsToCheck, cArgs, g_fControlHostFeatures0));
     1698               rc, pProcess->pStartupInfo->cArgs, cArgsToCheck, cArgs, g_fControlHostFeatures0));
    15531699#endif
    15541700
     
    15561702     * Create the environment.
    15571703     */
    1558     uint32_t const cbEnv = pProcess->StartupInfo.cbEnv;
     1704    uint32_t const cbEnv = pProcess->pStartupInfo->cbEnv;
    15591705    if (RT_SUCCESS(rc))
    1560         AssertStmt(   cbEnv <= sizeof(pProcess->StartupInfo.szEnv)
    1561                    || pProcess->StartupInfo.uNumEnvVars == 0,
     1706        AssertStmt(   cbEnv <= GUESTPROCESS_MAX_ENV_LEN
     1707                   || pProcess->pStartupInfo->cEnvVars == 0,
    15621708                   rc = VERR_INVALID_PARAMETER);
    15631709    if (RT_SUCCESS(rc))
     
    15681714        {
    15691715            VGSvcVerbose(3, "Additional environment variables: %RU32 (%RU32 bytes)\n",
    1570                          pProcess->StartupInfo.uNumEnvVars, cbEnv);
    1571 
    1572             if (   pProcess->StartupInfo.uNumEnvVars /** @todo r=bird: s/uNumEnvVars/cEnvVars/g */
     1716                         pProcess->pStartupInfo->cEnvVars, cbEnv);
     1717
     1718            if (   pProcess->pStartupInfo->cEnvVars
    15731719                && cbEnv > 0)
    15741720            {
     
    15761722                while (offCur < cbEnv)
    15771723                {
    1578                     const char * const pszCur = &pProcess->StartupInfo.szEnv[offCur];
     1724                    const char * const pszCur = &pProcess->pStartupInfo->pszEnv[offCur];
    15791725                    size_t const       cchCur = RTStrNLen(pszCur, cbEnv - offCur);
    15801726                    AssertBreakStmt(cchCur < cbEnv - offCur, rc = VERR_INVALID_PARAMETER);
     
    16051751                    RTHANDLE    hStdOut;
    16061752                    PRTHANDLE   phStdOut;
    1607                     rc = vgsvcGstCtrlProcessSetupPipe(  (pProcess->StartupInfo.uFlags & EXECUTEPROCESSFLAG_WAIT_STDOUT)
     1753                    rc = vgsvcGstCtrlProcessSetupPipe(  (pProcess->pStartupInfo->fFlags & EXECUTEPROCESSFLAG_WAIT_STDOUT)
    16081754                                                 ? "|" : "/dev/null",
    16091755                                                 1 /*STDOUT_FILENO*/,
     
    16131759                        RTHANDLE    hStdErr;
    16141760                        PRTHANDLE   phStdErr;
    1615                         rc = vgsvcGstCtrlProcessSetupPipe(  (pProcess->StartupInfo.uFlags & EXECUTEPROCESSFLAG_WAIT_STDERR)
     1761                        rc = vgsvcGstCtrlProcessSetupPipe(  (pProcess->pStartupInfo->fFlags & EXECUTEPROCESSFLAG_WAIT_STDERR)
    16161762                                                     ? "|" : "/dev/null",
    16171763                                                     2 /*STDERR_FILENO*/,
     
    16541800                                    bool fNeedsImpersonation = !(pProcess->pSession->fFlags & VBOXSERVICECTRLSESSION_FLAG_SPAWN);
    16551801
    1656                                     rc = vgsvcGstCtrlProcessCreateProcess(pProcess->StartupInfo.szCmd, papszArgs, hEnv,
    1657                                                                      pProcess->StartupInfo.uFlags,
     1802                                    rc = vgsvcGstCtrlProcessCreateProcess(pProcess->pStartupInfo->pszCmd, papszArgs, hEnv,
     1803                                                                     pProcess->pStartupInfo->fFlags,
    16581804                                                                     phStdIn, phStdOut, phStdErr,
    1659                                                                      fNeedsImpersonation ? pProcess->StartupInfo.szUser     : NULL,
    1660                                                                      fNeedsImpersonation ? pProcess->StartupInfo.szPassword : NULL,
    1661                                                                      fNeedsImpersonation ? pProcess->StartupInfo.szDomain   : NULL,
     1805                                                                     fNeedsImpersonation ? pProcess->pStartupInfo->pszUser     : NULL,
     1806                                                                     fNeedsImpersonation ? pProcess->pStartupInfo->pszPassword : NULL,
     1807                                                                     fNeedsImpersonation ? pProcess->pStartupInfo->pszDomain   : NULL,
    16621808                                                                     &pProcess->hProcess);
    16631809                                    if (RT_FAILURE(rc))
     
    17721918
    17731919    VGSvcVerbose(3, "[PID %RU32]: Thread of process '%s' ended with rc=%Rrc (fSignalled=%RTbool)\n",
    1774                  pProcess->uPID, pProcess->StartupInfo.szCmd, rc, fSignalled);
     1920                 pProcess->uPID, pProcess->pStartupInfo->pszCmd, rc, fSignalled);
    17751921
    17761922    return rc;
     
    18451991        {
    18461992            VGSvcError("Creating thread for guest process '%s' failed: rc=%Rrc, pProcess=%p\n",
    1847                        pStartupInfo->szCmd, rc, pProcess);
     1993                       pStartupInfo->pszCmd, rc, pProcess);
    18481994
    18491995            VGSvcGstCtrlProcessFree(pProcess);
     
    18602006                || RT_FAILURE(rc))
    18612007            {
    1862                 VGSvcError("Thread for process '%s' failed to start, rc=%Rrc\n", pStartupInfo->szCmd, rc);
     2008                VGSvcError("Thread for process '%s' failed to start, rc=%Rrc\n", pStartupInfo->pszCmd, rc);
    18632009                int rc2 = RTThreadWait(pProcess->Thread, RT_MS_1SEC * 30, NULL);
    18642010                if (RT_SUCCESS(rc2))
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r83612 r84147  
    10261026}
    10271027
     1028/**
     1029 * Initializes a session startup info.
     1030 *
     1031 * @returns VBox status code.
     1032 * @param   pStartupInfo        Session startup info to initializes.
     1033 */
     1034int VgsvcGstCtrlSessionStartupInfoInit(PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfo)
     1035{
     1036    AssertPtrReturn(pStartupInfo, VERR_INVALID_POINTER);
     1037
     1038    RT_BZERO(pStartupInfo, sizeof(VBOXSERVICECTRLSESSIONSTARTUPINFO));
     1039
     1040#define ALLOC_STR(a_Str, a_cb) \
     1041    if ((a_cb) > 0) \
     1042    { \
     1043        pStartupInfo->psz##a_Str = RTStrAlloc(a_cb); \
     1044        AssertPtrBreak(pStartupInfo->psz##a_Str); \
     1045        pStartupInfo->cb##a_Str  = a_cb; \
     1046    }
     1047
     1048    do
     1049    {
     1050        ALLOC_STR(User,     sizeof(char) * GUESTPROCESS_MAX_USER_LEN);
     1051        ALLOC_STR(Password, sizeof(char) * GUESTPROCESS_MAX_PASSWORD_LEN);
     1052        ALLOC_STR(Domain,   sizeof(char) * GUESTPROCESS_MAX_DOMAIN_LEN);
     1053
     1054        return VINF_SUCCESS;
     1055
     1056    } while (0);
     1057
     1058#undef ALLOC_STR
     1059
     1060    VgsvcGstCtrlSessionStartupInfoDestroy(pStartupInfo);
     1061    return VERR_NO_MEMORY;
     1062}
     1063
     1064/**
     1065 * Destroys a session startup info.
     1066 *
     1067 * @param   pStartupInfo        Session startup info to destroy.
     1068 */
     1069void VgsvcGstCtrlSessionStartupInfoDestroy(PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfo)
     1070{
     1071    if (!pStartupInfo)
     1072        return;
     1073
     1074    RTStrFree(pStartupInfo->pszUser);
     1075    RTStrFree(pStartupInfo->pszPassword);
     1076    RTStrFree(pStartupInfo->pszDomain);
     1077
     1078    RT_BZERO(pStartupInfo, sizeof(VBOXSERVICECTRLSESSIONSTARTUPINFO));
     1079}
     1080
     1081/**
     1082 * Free's a session startup info.
     1083 *
     1084 * @param   pStartupInfo        Session startup info to free.
     1085 *                              The pointer will not be valid anymore after return.
     1086 */
     1087static void vgsvcGstCtrlSessionStartupInfoFree(PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfo)
     1088{
     1089    if (!pStartupInfo)
     1090        return;
     1091
     1092    VgsvcGstCtrlSessionStartupInfoDestroy(pStartupInfo);
     1093
     1094    RTMemFree(pStartupInfo);
     1095    pStartupInfo = NULL;
     1096}
     1097
     1098/**
     1099 * Duplicates a session startup info.
     1100 *
     1101 * @returns Duplicated session startup info on success, or NULL on error.
     1102 * @param   pStartupInfo        Session startup info to duplicate.
     1103 */
     1104static PVBOXSERVICECTRLSESSIONSTARTUPINFO vgsvcGstCtrlSessionStartupInfoDup(PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfo)
     1105{
     1106    AssertPtrReturn(pStartupInfo, NULL);
     1107
     1108    PVBOXSERVICECTRLSESSIONSTARTUPINFO pStartupInfoDup = (PVBOXSERVICECTRLSESSIONSTARTUPINFO)
     1109                                                                RTMemDup(pStartupInfo, sizeof(VBOXSERVICECTRLSESSIONSTARTUPINFO));
     1110    if (pStartupInfoDup)
     1111    {
     1112        do
     1113        {
     1114            pStartupInfoDup->pszUser     = NULL;
     1115            pStartupInfoDup->pszPassword = NULL;
     1116            pStartupInfoDup->pszDomain   = NULL;
     1117
     1118#define DUP_STR(a_Str) \
     1119    if (pStartupInfo->cb##a_Str) \
     1120    { \
     1121        pStartupInfoDup->psz##a_Str = (char *)RTMemDup(pStartupInfo->psz##a_Str, pStartupInfo->cb##a_Str); \
     1122        AssertPtrBreak(pStartupInfoDup->psz##a_Str); \
     1123        pStartupInfoDup->cb##a_Str  = pStartupInfo->cb##a_Str; \
     1124    }
     1125            DUP_STR(User);
     1126            DUP_STR(Password);
     1127            DUP_STR(Domain);
     1128
     1129#undef DUP_STR
     1130
     1131            return pStartupInfoDup;
     1132
     1133        } while (0); /* To use break macros above. */
     1134
     1135        vgsvcGstCtrlSessionStartupInfoFree(pStartupInfoDup);
     1136    }
     1137
     1138    return NULL;
     1139}
    10281140
    10291141/**
     
    10451157     * will contain the actual block size. */
    10461158    VBOXSERVICECTRLPROCSTARTUPINFO startupInfo;
    1047     RT_ZERO(startupInfo);
    1048     startupInfo.cbEnv = sizeof(startupInfo.szEnv);
    1049 
    1050     int rc = VbglR3GuestCtrlProcGetStart(pHostCtx,
    1051                                          /* Command */
    1052                                          startupInfo.szCmd,      sizeof(startupInfo.szCmd),
    1053                                          /* Flags */
    1054                                          &startupInfo.uFlags,
    1055                                          /* Arguments */
    1056                                          startupInfo.szArgs,     sizeof(startupInfo.szArgs),    &startupInfo.uNumArgs,
    1057                                          /* Environment */
    1058                                          startupInfo.szEnv,      &startupInfo.cbEnv,            &startupInfo.uNumEnvVars,
    1059                                          /* Credentials; for hosts with VBox < 4.3 (protocol version 1).
    1060                                           * For protocol v2 and up the credentials are part of the session
    1061                                           * opening call. */
    1062                                          startupInfo.szUser,     sizeof(startupInfo.szUser),
    1063                                          startupInfo.szPassword, sizeof(startupInfo.szPassword),
    1064                                          /* Timeout (in ms) */
    1065                                          &startupInfo.uTimeLimitMS,
    1066                                          /* Process priority */
    1067                                          &startupInfo.uPriority,
    1068                                          /* Process affinity */
    1069                                          startupInfo.uAffinity,  sizeof(startupInfo.uAffinity), &startupInfo.uNumAffinity);
     1159    int rc = VgsvcGstCtrlProcessStartupInfoInit(&startupInfo);
     1160    if (RT_FAILURE(rc))
     1161        return rc;
     1162
     1163    rc = VbglR3GuestCtrlProcGetStart(pHostCtx,
     1164                                     /* Command */
     1165                                     startupInfo.pszCmd,      startupInfo.cbCmd,
     1166                                     /* Flags */
     1167                                     &startupInfo.fFlags,
     1168                                     /* Arguments */
     1169                                     startupInfo.pszArgs,     startupInfo.cbArgs,     &startupInfo.cArgs,
     1170                                     /* Environment */
     1171                                     startupInfo.pszEnv,      &startupInfo.cbEnv,     &startupInfo.cEnvVars,
     1172                                     /* Credentials; for hosts with VBox < 4.3 (protocol version 1).
     1173                                      * For protocol v2 and up the credentials are part of the session
     1174                                      * opening call. */
     1175                                     startupInfo.pszUser,     startupInfo.cbUser,
     1176                                     startupInfo.pszPassword, startupInfo.cbPassword,
     1177                                     /* Timeout (in ms) */
     1178                                     &startupInfo.uTimeLimitMS,
     1179                                     /* Process priority */
     1180                                     &startupInfo.uPriority,
     1181                                     /* Process affinity */
     1182                                     startupInfo.uAffinity,  sizeof(startupInfo.uAffinity), &startupInfo.uNumAffinity);
    10701183    if (RT_SUCCESS(rc))
    10711184    {
    10721185        VGSvcVerbose(3, "Request to start process szCmd=%s, fFlags=0x%x, szArgs=%s, szEnv=%s, uTimeout=%RU32\n",
    1073                      startupInfo.szCmd, startupInfo.uFlags,
    1074                      startupInfo.uNumArgs ? startupInfo.szArgs : "<None>",
    1075                      startupInfo.uNumEnvVars ? startupInfo.szEnv : "<None>",
     1186                     startupInfo.pszCmd, startupInfo.fFlags,
     1187                     startupInfo.cArgs ? startupInfo.pszArgs : "<None>",
     1188                     startupInfo.cEnvVars ? startupInfo.pszEnv : "<None>",
    10761189                     startupInfo.uTimeLimitMS);
    10771190
     
    11031216        VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX);
    11041217    }
     1218
     1219    VgsvcGstCtrlProcessStartupInfoDestroy(&startupInfo);
     1220
    11051221    return rc;
    11061222}
     
    14651581    AssertPtrReturn(pThread, VERR_INVALID_POINTER);
    14661582
    1467     uint32_t const idSession = pThread->StartupInfo.uSessionID;
     1583    uint32_t const idSession = pThread->pStartupInfo->uSessionID;
    14681584    uint32_t const idClient  = g_idControlSvcClient;
    14691585    VGSvcVerbose(3, "Session ID=%RU32 thread running\n", idSession);
     
    15181634                    /* .idClient  = */  idClient,
    15191635                    /* .idContext = */  VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(idSession),
    1520                     /* .uProtocol = */  pThread->StartupInfo.uProtocol,
     1636                    /* .uProtocol = */  pThread->pStartupInfo->uProtocol,
    15211637                    /* .cParams   = */  2
    15221638                };
     
    21802296     * privileges as the main VBoxService executable.
    21812297     */
    2182     bool const fAnonymous = pSessionThread->StartupInfo.szUser[0] == '\0';
     2298    bool const fAnonymous =    pSessionThread->pStartupInfo->pszUser
     2299                            && pSessionThread->pStartupInfo->pszUser[0] == '\0';
    21832300    if (fAnonymous)
    21842301    {
    2185         Assert(!strlen(pSessionThread->StartupInfo.szPassword));
    2186         Assert(!strlen(pSessionThread->StartupInfo.szDomain));
     2302        Assert(!strlen(pSessionThread->pStartupInfo->pszPassword));
     2303        Assert(!strlen(pSessionThread->pStartupInfo->pszDomain));
    21872304
    21882305        VGSvcVerbose(3, "New anonymous guest session ID=%RU32 created, fFlags=%x, using protocol %RU32\n",
     
    21952312        VGSvcVerbose(3, "Spawning new guest session ID=%RU32, szUser=%s, szPassword=%s, szDomain=%s, fFlags=%x, using protocol %RU32\n",
    21962313                     pSessionStartupInfo->uSessionID,
    2197                      pSessionStartupInfo->szUser,
     2314                     pSessionStartupInfo->pszUser,
    21982315#ifdef DEBUG
    2199                      pSessionStartupInfo->szPassword,
     2316                     pSessionStartupInfo->pszPassword,
    22002317#else
    22012318                     "XXX", /* Never show passwords in release mode. */
    22022319#endif
    2203                      pSessionStartupInfo->szDomain,
     2320                     pSessionStartupInfo->pszDomain,
    22042321                     pSessionStartupInfo->fFlags,
    22052322                     pSessionStartupInfo->uProtocol);
     
    22152332
    22162333    char szParmSessionID[32];
    2217     RTStrPrintf(szParmSessionID, sizeof(szParmSessionID), "--session-id=%RU32", pSessionThread->StartupInfo.uSessionID);
     2334    RTStrPrintf(szParmSessionID, sizeof(szParmSessionID), "--session-id=%RU32", pSessionThread->pStartupInfo->uSessionID);
    22182335
    22192336    char szParmSessionProto[32];
    22202337    RTStrPrintf(szParmSessionProto, sizeof(szParmSessionProto), "--session-proto=%RU32",
    2221                 pSessionThread->StartupInfo.uProtocol);
     2338                pSessionThread->pStartupInfo->uProtocol);
    22222339#ifdef DEBUG
    22232340    char szParmThreadId[32];
     
    22372354    {
    22382355        apszArgs[idxArg++] = "--user";
    2239         apszArgs[idxArg++] = pSessionThread->StartupInfo.szUser;
    2240 
    2241         if (strlen(pSessionThread->StartupInfo.szDomain))
     2356        apszArgs[idxArg++] = pSessionThread->pStartupInfo->pszUser;
     2357
     2358        if (strlen(pSessionThread->pStartupInfo->pszDomain))
    22422359        {
    22432360            apszArgs[idxArg++] = "--domain";
    2244             apszArgs[idxArg++] = pSessionThread->StartupInfo.szDomain;
     2361            apszArgs[idxArg++] = pSessionThread->pStartupInfo->pszDomain;
    22452362        }
    22462363    }
     
    22902407#ifndef DEBUG
    22912408        RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%s-%s%s",
    2292                     cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, pSessionStartupInfo->szUser, szTime, pszSuffix);
     2409                    cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, pSessionStartupInfo->pszUser, szTime, pszSuffix);
    22932410#else
    22942411        RTStrPrintf(szParmLogFile, sizeof(szParmLogFile), "%.*s-%RU32-%RU32-%s-%s%s",
    22952412                    cchBase, g_szLogFile, pSessionStartupInfo->uSessionID, uCtrlSessionThread,
    2296                     pSessionStartupInfo->szUser, szTime, pszSuffix);
     2413                    pSessionStartupInfo->pszUser, szTime, pszSuffix);
    22972414#endif
    22982415        apszArgs[idxArg++] = "--logfile";
     
    23452462             *          with the domain name built-in, e.g. "joedoe@example.com".
    23462463             */
    2347             const char *pszUser    = pSessionThread->StartupInfo.szUser;
     2464            const char *pszUser    = pSessionThread->pStartupInfo->pszUser;
    23482465#ifdef RT_OS_WINDOWS
    23492466            char       *pszUserUPN = NULL;
    2350             if (pSessionThread->StartupInfo.szDomain[0])
     2467            if (pSessionThread->pStartupInfo->pszDomain[0])
    23512468            {
    23522469                int cchbUserUPN = RTStrAPrintf(&pszUserUPN, "%s@%s",
    2353                                                pSessionThread->StartupInfo.szUser,
    2354                                                pSessionThread->StartupInfo.szDomain);
     2470                                               pSessionThread->pStartupInfo->pszUser,
     2471                                               pSessionThread->pStartupInfo->pszDomain);
    23552472                if (cchbUserUPN > 0)
    23562473                {
     
    23702487                                    &hStdIn, &hStdOutAndErr, &hStdOutAndErr,
    23712488                                    !fAnonymous ? pszUser : NULL,
    2372                                     !fAnonymous ? pSessionThread->StartupInfo.szPassword : NULL,
     2489                                    !fAnonymous ? pSessionThread->pStartupInfo->pszPassword : NULL,
    23732490                                    NULL /*pvExtraData*/,
    23742491                                    &pSessionThread->hProcess);
     
    24132530    {
    24142531        AssertMsgReturn(   pSessionCur->fStopped == true
    2415                         || pSessionCur->StartupInfo.uSessionID != pSessionStartupInfo->uSessionID,
     2532                        || pSessionCur->pStartupInfo->uSessionID != pSessionStartupInfo->uSessionID,
    24162533                        ("Guest session thread ID=%RU32 already exists (fStopped=%RTbool)\n",
    2417                          pSessionCur->StartupInfo.uSessionID, pSessionCur->fStopped), VERR_ALREADY_EXISTS);
     2534                         pSessionCur->pStartupInfo->uSessionID, pSessionCur->fStopped), VERR_ALREADY_EXISTS);
    24182535    }
    24192536#endif
     
    24362553        pSessionThread->hProcess  = NIL_RTPROCESS;
    24372554
    2438         /* Copy over session startup info. */
    2439         memcpy(&pSessionThread->StartupInfo, pSessionStartupInfo, sizeof(VBOXSERVICECTRLSESSIONSTARTUPINFO));
     2555        /* Duplicate startup info. */
     2556        pSessionThread->pStartupInfo = vgsvcGstCtrlSessionStartupInfoDup(pSessionStartupInfo);
     2557        AssertPtrReturn(pSessionThread->pStartupInfo, VERR_NO_MEMORY);
    24402558
    24412559        /* Generate the secret key. */
     
    24822600                            && !ASMAtomicReadBool(&pSessionThread->fShutdown))
    24832601                        {
    2484                             VGSvcVerbose(2, "Thread for session ID=%RU32 started\n", pSessionThread->StartupInfo.uSessionID);
     2602                            VGSvcVerbose(2, "Thread for session ID=%RU32 started\n", pSessionThread->pStartupInfo->uSessionID);
    24852603
    24862604                            ASMAtomicXchgBool(&pSessionThread->fStarted, true);
     
    24972615                         */
    24982616                        VGSvcError("Thread for session ID=%RU32 failed to start, rc=%Rrc\n",
    2499                                    pSessionThread->StartupInfo.uSessionID, rc);
     2617                                   pSessionThread->pStartupInfo->uSessionID, rc);
    25002618                        if (RT_SUCCESS_NP(rc))
    25012619                            rc = VERR_CANT_CREATE; /** @todo Find a better rc. */
     
    25632681
    25642682        VGSvcVerbose(3, "Waiting for session thread ID=%RU32 to close (%RU32ms) ...\n",
    2565                      pThread->StartupInfo.uSessionID, uTimeoutMS);
     2683                     pThread->pStartupInfo->uSessionID, uTimeoutMS);
    25662684
    25672685        int rcThread;
     
    25702688        {
    25712689            AssertMsg(pThread->fStopped, ("Thread of session ID=%RU32 not in stopped state when it should\n",
    2572                       pThread->StartupInfo.uSessionID));
    2573 
    2574             VGSvcVerbose(3, "Session thread ID=%RU32 ended with rc=%Rrc\n", pThread->StartupInfo.uSessionID, rcThread);
     2690                      pThread->pStartupInfo->uSessionID));
     2691
     2692            VGSvcVerbose(3, "Session thread ID=%RU32 ended with rc=%Rrc\n", pThread->pStartupInfo->uSessionID, rcThread);
    25752693        }
    25762694        else
    2577             VGSvcError("Waiting for session thread ID=%RU32 to close failed with rc=%Rrc\n", pThread->StartupInfo.uSessionID, rc);
     2695            VGSvcError("Waiting for session thread ID=%RU32 to close failed with rc=%Rrc\n", pThread->pStartupInfo->uSessionID, rc);
    25782696    }
    25792697    else
    2580         VGSvcVerbose(3, "Thread for session ID=%RU32 not in started state, skipping wait\n", pThread->StartupInfo.uSessionID);
     2698        VGSvcVerbose(3, "Thread for session ID=%RU32 not in started state, skipping wait\n", pThread->pStartupInfo->uSessionID);
    25812699
    25822700    LogFlowFuncLeaveRC(rc);
     
    25952713{
    25962714    AssertPtrReturn(pThread, VERR_INVALID_POINTER);
    2597 
    2598     const uint32_t uSessionID = pThread->StartupInfo.uSessionID;
     2715    AssertPtrReturn(pThread->pStartupInfo, VERR_WRONG_ORDER);
     2716
     2717    const uint32_t uSessionID = pThread->pStartupInfo->uSessionID;
    25992718
    26002719    VGSvcVerbose(3, "Destroying session ID=%RU32 ...\n", uSessionID);
     
    26032722    if (RT_SUCCESS(rc))
    26042723    {
     2724        vgsvcGstCtrlSessionStartupInfoFree(pThread->pStartupInfo);
     2725        pThread->pStartupInfo = NULL;
     2726
    26052727        /* Remove session from list and destroy object. */
    26062728        RTListNodeRemove(&pThread->Node);
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