VirtualBox

Changeset 63156 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 8, 2016 12:11:53 PM (8 years ago)
Author:
vboxsync
Message:

GuestSession::i_objectCreateTempInternal,GuestSession::i_fsQueryInfoInternal: guestRc _was_ used uninitialized and pGuestRc not set when returning VERR_GSTCTL_GUEST_ERROR (local variable was updated instead). Changed procInfo initialization to return immediately when out of memory, as it makes the code flow unnecessarily complicated to do the single return point thing. The mExecutable was not inside the try/catch, as it need to be as it allocates memory too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r62379 r63156  
    827827                     strTemplate.c_str(), strPath.c_str(), fDirectory));
    828828
    829     int vrc = VINF_SUCCESS;
    830 
    831829    GuestProcessStartupInfo procInfo;
    832     procInfo.mFlags      = ProcessCreateFlag_WaitForStdOut;
    833     procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
    834 
     830    procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;
    835831    try
    836832    {
     833        procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
    837834        procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */
    838835        procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
     
    849846    catch (std::bad_alloc)
    850847    {
    851         vrc = VERR_NO_MEMORY;
     848        Log(("Out of memory!\n"));
     849        return VERR_NO_MEMORY;
    852850    }
    853851
    854852    /** @todo Use an internal HGCM command for this operation, since
    855853     *        we now can run in a user-dedicated session. */
    856     int guestRc;
     854    int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
    857855    GuestCtrlStreamObjects stdOut;
    858     if (RT_SUCCESS(vrc))
    859         vrc = GuestProcessTool::i_runEx(this, procInfo,
     856    int vrc = GuestProcessTool::i_runEx(this, procInfo,
    860857                                        &stdOut, 1 /* cStrmOutObjects */,
    861                                         &guestRc);
    862 
     858                                        &vrcGuest);
    863859    if (!GuestProcess::i_isGuestError(vrc))
    864860    {
     
    869865            if (RT_FAILURE(vrc))
    870866            {
    871                 guestRc = vrc;
     867                if (pGuestRc)
     868                    *pGuestRc = vrc;
    872869                vrc = VERR_GSTCTL_GUEST_ERROR;
    873870            }
     
    880877    }
    881878    else if (pGuestRc)
    882     {
    883         *pGuestRc = guestRc;
    884     }
     879        *pGuestRc = vrcGuest;
    885880
    886881    LogFlowThisFunc(("Returning rc=%Rrc, guestRc=%Rrc\n", vrc, guestRc));
     
    14021397    LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
    14031398
    1404     int vrc = VINF_SUCCESS;
    1405 
    14061399    /** @todo Merge this with IGuestFile::queryInfo(). */
    14071400    GuestProcessStartupInfo procInfo;
    14081401    procInfo.mFlags      = ProcessCreateFlag_WaitForStdOut;
    1409     procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_STAT);
    1410 
    14111402    try
    14121403    {
     1404        procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_STAT);
    14131405        procInfo.mArguments.push_back(procInfo.mExecutable); /* Set argv0. */
    14141406        procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
     
    14201412    catch (std::bad_alloc)
    14211413    {
    1422         vrc = VERR_NO_MEMORY;
    1423     }
    1424 
    1425     int guestRc;
     1414        Log(("Out of memory!\n"));
     1415        return VERR_NO_MEMORY;
     1416    }
     1417
     1418    int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS;
    14261419    GuestCtrlStreamObjects stdOut;
    1427     if (RT_SUCCESS(vrc))
    1428         vrc = GuestProcessTool::i_runEx(this, procInfo,
     1420    int vrc = GuestProcessTool::i_runEx(this, procInfo,
    14291421                                        &stdOut, 1 /* cStrmOutObjects */,
    1430                                         &guestRc);
    1431 
     1422                                        &vrcGuest);
    14321423    if (!GuestProcess::i_isGuestError(vrc))
    14331424    {
     
    14371428            if (RT_FAILURE(vrc))
    14381429            {
    1439                 guestRc = vrc;
     1430                if (pGuestRc)
     1431                    *pGuestRc = vrc;
    14401432                vrc = VERR_GSTCTL_GUEST_ERROR;
    14411433            }
     
    14451437    }
    14461438    else if (pGuestRc)
    1447     {
    1448         *pGuestRc = guestRc;
    1449     }
     1439        *pGuestRc = vrcGuest;
    14501440
    14511441    LogFlowThisFunc(("Returning rc=%Rrc, guestRc=%Rrc\n", vrc, guestRc));
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