VirtualBox

Changeset 16209 in vbox


Ignore:
Timestamp:
Jan 23, 2009 6:48:23 PM (16 years ago)
Author:
vboxsync
Message:

OVF: fix ulong overflow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r16208 r16209  
    800800}
    801801
    802 STDMETHODIMP Appliance::GetDisks (ComSafeArrayOut(BSTR, aDisks), ULONG *cDisks)
     802STDMETHODIMP Appliance::GetDisks(ComSafeArrayOut(BSTR, aDisks), ULONG *cDisks)
    803803{
    804804    CheckComArgOutSafeArrayPointerValid(aDisks);
     
    852852}
    853853
    854 STDMETHODIMP Appliance::COMGETTER (VirtualSystemDescriptions)(ComSafeArrayOut (IVirtualSystemDescription*, aVirtualSystemDescriptions))
     854STDMETHODIMP Appliance::COMGETTER(VirtualSystemDescriptions)(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions))
    855855{
    856856    CheckComArgOutSafeArrayPointerValid (aVirtualSystemDescriptions);
     
    979979    //  - don't use COM methods but the methods directly (faster, but needs appropriate locking of that objects itself (s. HardDisk2))
    980980    //  - Appropriate handle errors like not supported file formats
    981     //  - Maybe it is better to replace std::string with Utf8Str's on some places?
    982981
    983982    /* Clear any previous virtual system descriptions */
     
    12081207
    12091208        /* RAM */
    1210         ULONG memSizeVBox = vs.ullMemorySize; /** @todo r=bird/MSC: this will overflow at 4GB, use 64-bit type. */
     1209        uint64_t ullMemSizeVBox = vs.ullMemorySize; /** @todo r=bird/MSC: this will overflow at 4GB, use 64-bit type. */
    12111210        if (vs.ullMemorySize == 0)
    12121211        {
    12131212            /* If the RAM of the OVF is zero, use our predefined values */
    1214             rc = osType->COMGETTER(RecommendedRAM) (&memSizeVBox);
     1213            ULONG memSizeVBox2;
     1214            rc = osType->COMGETTER(RecommendedRAM)(&memSizeVBox2);
    12151215            ComAssertComRCThrowRC (rc);
    12161216            /* VBox stores that in MByte */
    1217             memSizeVBox *= _1M;
    1218         }
    1219         vsd->addEntry (VirtualSystemDescriptionType_Memory, 0, toString<ULONG> (vs.ullMemorySize), toString<ULONG> (memSizeVBox));
     1217            ullMemSizeVBox = memSizeVBox2 * _1M;
     1218        }
     1219        vsd->addEntry (VirtualSystemDescriptionType_Memory, 0, toString<uint64_t> (vs.ullMemorySize), toString<uint64_t> (ullMemSizeVBox));
    12201220
    12211221        /* Hard disk Controller */
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