VirtualBox

Changeset 84243 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
May 11, 2020 9:59:59 AM (5 years ago)
Author:
vboxsync
Message:

Guest Control: Implemented support for long(er) command lines. bugref:9320

File:
1 edited

Legend:

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

    r83472 r84243  
    10581058    const GuestCredentials &sessionCreds = pSession->i_getCredentials();
    10591059
    1060 
    10611060    /* Prepare arguments. */
    10621061    size_t cArgs = mData.mProcess.mArguments.size();
     
    10641063        return VERR_BUFFER_OVERFLOW;
    10651064
     1065    Guest *pGuest = mSession->i_getParent();
     1066    AssertPtr(pGuest);
     1067
     1068    const uint64_t fGuestControlFeatures0 = pGuest->i_getGuestControlFeatures0();
     1069
     1070    /* If the guest does not support dynamic sizes, make sure that we check limits here. */
     1071    if (   !(fGuestControlFeatures0 & VBOX_GUESTCTRL_GF_0_PROCESS_DYNAMIC_SIZES)
     1072        &&  mData.mProcess.mExecutable.length() + 1 /* Include termination */ > GUESTPROCESS_DEFAULT_CMD_LEN)
     1073        return VERR_BUFFER_OVERFLOW;
     1074
     1075    size_t cbArgs = 0;
    10661076    char *pszArgs = NULL;
    10671077    int vrc = VINF_SUCCESS;
     
    10771087        }
    10781088        papszArgv[cArgs] = NULL;
    1079 
    1080         Guest *pGuest = mSession->i_getParent();
    1081         AssertPtr(pGuest);
    1082 
    1083         const uint64_t fGuestControlFeatures0 = pGuest->i_getGuestControlFeatures0();
    10841089
    10851090        /* If the Guest Additions don't support using argv[0] correctly (< 6.1.x), don't supply it. */
     
    10931098            return vrc;
    10941099
    1095         /* Note! No returns after this. */
    1096     }
    1097 
    1098     /* Calculate arguments size (in bytes). */
    1099     size_t cbArgs = pszArgs ? strlen(pszArgs) + 1 : 0; /* Include terminating zero. */
     1100        /* Note! No direct returns after this. */
     1101
     1102        /* Calculate arguments size (in bytes). */
     1103        AssertPtr(pszArgs);
     1104        cbArgs = strlen(pszArgs) + 1; /* Include terminating zero. */
     1105
     1106        /* If the guest does not support dynamic sizes, make sure that we check limits here. */
     1107        if (   !(fGuestControlFeatures0 & VBOX_GUESTCTRL_GF_0_PROCESS_DYNAMIC_SIZES)
     1108            && cbArgs > GUESTPROCESS_DEFAULT_ARGS_LEN)
     1109        {
     1110            vrc = VERR_BUFFER_OVERFLOW;
     1111        }
     1112    }
    11001113
    11011114    /* Prepare environment.  The guest service dislikes the empty string at the end, so drop it. */
    11021115    size_t  cbEnvBlock;
    11031116    char   *pszzEnvBlock;
    1104     vrc = mData.mProcess.mEnvironmentChanges.queryUtf8Block(&pszzEnvBlock, &cbEnvBlock);
     1117    if (RT_SUCCESS(vrc))
     1118        vrc = mData.mProcess.mEnvironmentChanges.queryUtf8Block(&pszzEnvBlock, &cbEnvBlock);
     1119    if (RT_SUCCESS(vrc))
     1120    {
     1121        /* If the guest does not support dynamic sizes, make sure that we check limits here. */
     1122        if (   !(fGuestControlFeatures0 & VBOX_GUESTCTRL_GF_0_PROCESS_DYNAMIC_SIZES)
     1123            && cbEnvBlock > GUESTPROCESS_DEFAULT_ENV_LEN)
     1124            vrc = VERR_BUFFER_OVERFLOW;
     1125    }
     1126
    11051127    if (RT_SUCCESS(vrc))
    11061128    {
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