VirtualBox

Changeset 42168 in vbox


Ignore:
Timestamp:
Jul 16, 2012 2:46:12 PM (13 years ago)
Author:
vboxsync
Message:

Main/VirtualBox: must use different algorithm for duplicate elimination, as sorting destroys the order of VM groups and this would make the definition of primary group meaningless

File:
1 edited

Legend:

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

    r42131 r42168  
    30383038        com::SafeArray<IN_BSTR> machineGroups(ComSafeArrayInArg(aMachineGroups));
    30393039        for (size_t i = 0; i < machineGroups.size(); i++)
    3040             pllMachineGroups->push_back(machineGroups[i]);
    3041         pllMachineGroups->sort();
    3042         pllMachineGroups->unique();
    3043         if (pllMachineGroups->size() > 0)
     3040        {
     3041            Utf8Str group(machineGroups[i]);
     3042            if (group.length() == 0)
     3043                group = "/";
     3044            /* must start with a slash */
     3045            if (group.c_str()[0] != '/')
     3046                return E_INVALIDARG;
     3047            /* must not end with a slash */
     3048            if (group.length() > 1 && group.c_str()[group.length() - 1] == '/')
     3049                return E_INVALIDARG;
     3050
     3051            /** @todo validate each component of the group hierarchy */
     3052
     3053            /* no duplicates please */
     3054            if (   find(pllMachineGroups->begin(), pllMachineGroups->end(), group)
     3055                == pllMachineGroups->end())
     3056                pllMachineGroups->push_back(group);
     3057        }
     3058        if (pllMachineGroups->size() == 0)
    30443059            pllMachineGroups->push_back("/");
    3045         else if (pllMachineGroups->front().equals(""))
    3046         {
    3047             pllMachineGroups->pop_front();
    3048             if (pllMachineGroups->size() == 0 || !pllMachineGroups->front().equals("/"))
    3049                 pllMachineGroups->push_front("/");
    3050         }
    30513060    }
    30523061    else
    30533062        pllMachineGroups->push_back("/");
    3054 
    3055     for (StringsList::const_iterator it = pllMachineGroups->begin();
    3056          it != pllMachineGroups->end();
    3057          ++it)
    3058     {
    3059         const Utf8Str &str = *it;
    3060         /* no empty strings (shouldn't happen after the translation above) */
    3061         if (str.length() == 0)
    3062             return E_INVALIDARG;
    3063         /* must start with a slash */
    3064         if (str.c_str()[0] != '/')
    3065             return E_INVALIDARG;
    3066         /* must not end with a slash */
    3067         if (str.c_str()[str.length() - 1] != '/')
    3068             return E_INVALIDARG;
    3069 
    3070         /** @todo validate each component of the group hierarchy */
    3071     }
    30723063
    30733064    return S_OK;
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