VirtualBox

Ignore:
Timestamp:
Aug 4, 2008 4:03:45 PM (16 years ago)
Author:
vboxsync
Message:

FE/VBoxManage: fix guest property enumeration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestProp.cpp

    r11105 r11110  
    190190 * arguments.
    191191 */
    192     const char *paszPatterns = NULL;
    193     if ((argc > 2) && (0 == strcmp(argv[0], "-patterns")))
    194         paszPatterns = argv[1];
    195     else if (argc != 1)
    196         return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
    197 
    198 /*
    199  * Count the size of the patterns and pack them.
    200  */
    201     size_t cchPatterns = 0;
    202     if (argc > 2)
    203         for (int i = 1; i < argc; ++i)
    204             cchPatterns += strlen(argv[i]) + 1;
    205     Utf8Str Utf8Patterns(cchPatterns);
    206     if ((cchPatterns > 0) && Utf8Patterns.isNull())
    207         return errorArgument ("out of memory");
    208     char *pszPatterns = Utf8Patterns.mutableRaw();
    209     size_t iPatterns = 0;
    210     if (argc > 2)
    211     {
    212         for (int i = 1; i < argc; ++i)
    213         {
    214             strcpy(pszPatterns + iPatterns, argv[i]);
    215             iPatterns += strlen(argv[i]) + 1;
    216             pszPatterns[iPatterns - 1] = ',';
    217         }
    218         pszPatterns[iPatterns - 1] = '\0';
    219     }
     192    if ((argc < 1) || (2 == argc) ||
     193        ((argc > 3) && strcmp(argv[1], "-patterns") != 0))
     194        return errorSyntax(USAGE_GUESTPROPERTY, "Incorrect parameters");
     195
     196/*
     197 * Pack the patterns
     198 */
     199    Utf8Str Utf8Patterns(argc > 2 ? argv[2] : "");
     200    for (ssize_t i = 3; i < argc; ++i)
     201        Utf8Patterns = Utf8StrFmt ("%s,%s", Utf8Patterns.raw(), argv[i]);
    220202
    221203/*
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