VirtualBox

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


Ignore:
Timestamp:
Jul 12, 2020 1:58:25 PM (5 years ago)
Author:
vboxsync
Message:

Main/UnattendedImpl.cpp: Signed/unsigned conversion issues wrt Port and Device numbers. Limits are ULONG whereas all other arguments are LONG. bugref:9790

File:
1 edited

Legend:

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

    r84993 r85277  
    5656    StorageBus_T    enmBus;
    5757    Utf8Str         strControllerName;
    58     ULONG           uPort;
    59     ULONG           uDevice;
     58    LONG            iPort;
     59    LONG            iDevice;
    6060    bool            fFree;
    6161
    62     ControllerSlot(StorageBus_T a_enmBus, const Utf8Str &a_rName, ULONG a_uPort, ULONG a_uDevice, bool a_fFree)
    63         : enmBus(a_enmBus), strControllerName(a_rName), uPort(a_uPort), uDevice(a_uDevice), fFree(a_fFree)
     62    ControllerSlot(StorageBus_T a_enmBus, const Utf8Str &a_rName, LONG a_iPort, LONG a_iDevice, bool a_fFree)
     63        : enmBus(a_enmBus), strControllerName(a_rName), iPort(a_iPort), iDevice(a_iDevice), fFree(a_fFree)
    6464    {}
    6565
     
    7070            if (strControllerName == rThat.strControllerName)
    7171            {
    72                 if (uPort == rThat.uPort)
    73                     return uDevice < rThat.uDevice;
    74                 return uPort < rThat.uPort;
     72                if (iPort == rThat.iPort)
     73                    return iDevice < rThat.iDevice;
     74                return iPort < rThat.iPort;
    7575            }
    7676            return strControllerName < rThat.strControllerName;
     
    103103        return enmBus            == rThat.enmBus
    104104            && strControllerName == rThat.strControllerName
    105             && uPort             == rThat.uPort
    106             && uDevice           == rThat.uDevice;
     105            && iPort             == rThat.iPort
     106            && iDevice           == rThat.iDevice;
    107107    }
    108108};
     
    119119    DeviceType_T    enmDeviceType;
    120120    AccessMode_T    enmAccessType;
    121     ULONG           uPort;
    122     ULONG           uDevice;
     121    LONG            iPort;
     122    LONG            iDevice;
    123123    bool            fMountOnly;
    124124    Utf8Str         strImagePath;
    125125
    126126    UnattendedInstallationDisk(StorageBus_T a_enmBusType, Utf8Str const &a_rBusName, DeviceType_T a_enmDeviceType,
    127                                AccessMode_T a_enmAccessType, ULONG a_uPort, ULONG a_uDevice, bool a_fMountOnly,
     127                               AccessMode_T a_enmAccessType, LONG a_iPort, LONG a_iDevice, bool a_fMountOnly,
    128128                               Utf8Str const &a_rImagePath)
    129129        : enmBusType(a_enmBusType), strControllerName(a_rBusName), enmDeviceType(a_enmDeviceType), enmAccessType(a_enmAccessType)
    130         , uPort(a_uPort), uDevice(a_uDevice), fMountOnly(a_fMountOnly), strImagePath(a_rImagePath)
     130        , iPort(a_iPort), iDevice(a_iDevice), fMountOnly(a_fMountOnly), strImagePath(a_rImagePath)
    131131    {
    132132        Assert(strControllerName.length() > 0);
     
    135135    UnattendedInstallationDisk(std::list<ControllerSlot>::const_iterator const &itDvdSlot, Utf8Str const &a_rImagePath)
    136136        : enmBusType(itDvdSlot->enmBus), strControllerName(itDvdSlot->strControllerName), enmDeviceType(DeviceType_DVD)
    137         , enmAccessType(AccessMode_ReadOnly), uPort(itDvdSlot->uPort), uDevice(itDvdSlot->uDevice)
     137        , enmAccessType(AccessMode_ReadOnly), iPort(itDvdSlot->iPort), iDevice(itDvdSlot->iDevice)
    138138        , fMountOnly(!itDvdSlot->fFree), strImagePath(a_rImagePath)
    139139    {
     
    11051105                        psz++;
    11061106                    while (RT_C_IS_ALNUM(*psz) || *psz == '_');
    1107                     size_t cchIdentifier = psz - pszIdentifier;
     1107                    size_t cchIdentifier = (size_t)(psz - pszIdentifier);
    11081108
    11091109                    /* Skip to the value. */
     
    19401940     * Iterate thru all possible slots, adding those not found in arrayOfUsedSlots.
    19411941     */
    1942     for (uint32_t iPort = 0; iPort < cPorts; iPort++)
    1943         for (uint32_t iDevice = 0; iDevice < cMaxDevicesPerPort; iDevice++)
     1942    for (int32_t iPort = 0; iPort < (int32_t)cPorts; iPort++)
     1943        for (int32_t iDevice = 0; iDevice < (int32_t)cMaxDevicesPerPort; iDevice++)
    19441944        {
    19451945            bool fFound = false;
    19461946            for (size_t i = 0; i < arrayOfUsedSlots.size(); i++)
    1947                 if (   arrayOfUsedSlots[i].uPort   == iPort
    1948                     && arrayOfUsedSlots[i].uDevice == iDevice)
     1947                if (   arrayOfUsedSlots[i].iPort   == iPort
     1948                    && arrayOfUsedSlots[i].iDevice == iDevice)
    19491949                {
    19501950                    fFound = true;
     
    19771977    hrc = pController->COMSETTER(PortCount)(cPorts + (ULONG)cNewPortsNeeded);
    19781978    AssertComRCReturn(hrc, hrc);
    1979     for (uint32_t iPort = cPorts; iPort < cPorts + cNewPortsNeeded; iPort++)
    1980         for (uint32_t iDevice = 0; iDevice < cMaxDevicesPerPort; iDevice++)
     1979    int32_t const cPortsNew = (int32_t)(cPorts + cNewPortsNeeded);
     1980    for (int32_t iPort = (int32_t)cPorts; iPort < cPortsNew; iPort++)
     1981        for (int32_t iDevice = 0; iDevice < (int32_t)cMaxDevicesPerPort; iDevice++)
    19811982        {
    19821983            rDvdSlots.push_back(ControllerSlot(enmStorageBus, rStrControllerName, iPort, iDevice, true /*fFree*/));
     
    27022703        {
    27032704            // mount the opened disk image
    2704             rc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->uPort,
    2705                                                  pImage->uDevice, ptrMedium, TRUE /*fForce*/);
     2705            rc = rPtrSessionMachine->MountMedium(Bstr(pImage->strControllerName).raw(), pImage->iPort,
     2706                                                 pImage->iDevice, ptrMedium, TRUE /*fForce*/);
    27062707            LogRelFlowFunc(("Machine::MountMedium -> %Rhrc\n", rc));
    27072708        }
     
    27092710        {
    27102711            //attach the opened disk image to the controller
    2711             rc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->uPort,
    2712                                                   pImage->uDevice, pImage->enmDeviceType, ptrMedium);
     2712            rc = rPtrSessionMachine->AttachDevice(Bstr(pImage->strControllerName).raw(), pImage->iPort,
     2713                                                  pImage->iDevice, pImage->enmDeviceType, ptrMedium);
    27132714            LogRelFlowFunc(("Machine::AttachDevice -> %Rhrc\n", rc));
    27142715        }
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