VirtualBox

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


Ignore:
Timestamp:
May 26, 2020 10:24:15 AM (5 years ago)
Author:
vboxsync
Message:

bugref:9416. Used RTRandU64() instead the class com::Guid to generate suffix for VM name.

File:
1 edited

Legend:

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

    r84472 r84531  
    3232#include <iprt/crypto/store.h>
    3333#include <iprt/crypto/x509.h>
     34#include <iprt/rand.h>
    3435
    3536#include <VBox/vd.h>
     
    14281429            if (SUCCEEDED(hrc))
    14291430            {
    1430                 /** @todo r=bird: Please try find a less convoluted way of adding some random
    1431                  *        number to the name, we've got RTRandU64() for instance which you
    1432                  *        could combine with strVMName.appendPrintfNoThrow.
    1433                  *
    1434                  *        The code below is also accessing heap after it has been freed.
    1435                  *        Guid.toString() returns a Utf8Str object which expires and is deleted
    1436                  *        once strrchr returns.
    1437                  */
    14381431                /* what to do? create a new name from the old one with some suffix? */
    1439                 com::Guid newId;
    1440                 newId.create();
    1441                 /*
    1442                  * GUID has the string form "00000000-0000-0000-0000-00000000000".
    1443                  * Find the last part and append only it. The last 12 characters.
    1444                  */
    1445                 const char* cpLast = strrchr(newId.toString().c_str(), '-');
    1446                 strVMName.append("__").append(cpLast+1);
     1432                uint64_t suff = RTRandU64();
     1433                strVMName.append("__").appendPrintfNoThrow("%ul", suff);
    14471434
    14481435                vsd->RemoveDescriptionByType(VirtualSystemDescriptionType_Name);
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